Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 292182 Details for
Bug 429327
IPMI hardware steals ports; bind to these ports so that they are not used by accident
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
code to bind to an ipmi port
ipmi_port.c (text/plain), 2.68 KB, created by
Jeff Moyer
on 2008-01-18 18:25:10 UTC
(
hide
)
Description:
code to bind to an ipmi port
Filename:
MIME Type:
Creator:
Jeff Moyer
Created:
2008-01-18 18:25:10 UTC
Size:
2.68 KB
patch
obsolete
>/* > * ipmi_port.c > * Allocate the RMCP port (623.) with a bind so that port manager > * does not try to reuse it. Only needed for Linux. > * > * Changes: > * 05/18/07 Andy Cress - created > */ >#include <stdio.h> >#include <stdlib.h> >#include <unistd.h> >#include <fcntl.h> >#include <netinet/in.h> >#include <sys/types.h> >#include <sys/socket.h> > >#define RMCP_PORT 623 >char *progver = "0.1"; /* program version */ >char *progname = "ipmi_port"; /* program name */ >static int sockfd = 0; >static struct sockaddr_in _srcaddr; > >static int mkdaemon(int fchdir, int fclose); >static int mkdaemon(int fchdir, int fclose) >{ > int fdlimit = sysconf(_SC_OPEN_MAX); > int fd = 0; > > switch (fork()) { > case 0: break; > case -1: return -1; > default: _exit(0); /* exit the original process */ > } > if (setsid() < 0) return -1; /* shouldn't fail */ > switch (fork()) { > case 0: break; > case -1: return -1; > default: _exit(0); > } > if (fchdir) chdir("/"); > if (fclose) { > /* Close stdin,stdout,stderr and replace them with /dev/null */ > while (fd < fdlimit) close(fd++); > open("/dev/null",O_RDWR); > dup(0); dup(0); > } > return 0; >} > >static int open_rmcp_port(int port); >static int open_rmcp_port(int port) >{ > int rv; > > /* Open a socket binding to the RMCP port */ > rv = socket(AF_INET, SOCK_DGRAM, 0); > if (rv < 0) return (rv); > else sockfd = rv; > > memset(&_srcaddr, 0, sizeof(_srcaddr)); > _srcaddr.sin_family = AF_INET; > _srcaddr.sin_port = htons(port); > _srcaddr.sin_addr.s_addr = htonl(INADDR_ANY); > rv = bind(sockfd, (struct sockaddr *)&_srcaddr, sizeof(_srcaddr)); > if (rv < 0) { > printf("bind(%d,%d) error, rv = %d\n",port,INADDR_ANY,rv); > close(sockfd); > return (rv); > } > > return(rv); >} > > >int main(int argc, char **argv) >{ > int rv; > int c; > int background = 0; > > while ((c = getopt(argc, argv, "b?")) != EOF) { > switch (c) { > case 'b': background = 1; break; > default: > printf("Usage: %s [-b] (-b means background)\n",progname); > exit(1); > } > } > > rv = open_rmcp_port(RMCP_PORT); > if (rv != 0) printf("open_rmcp_port(%d) failed, rv = %d\n",RMCP_PORT,rv); > else printf("open_rmcp_port(%d) succeeded, sleeping\n",RMCP_PORT); > > /* convert to a daemon if background */ > if (background) { > rv = mkdaemon(1,1); > if (rv != 0) { > printf("%s: Cannot become daemon, rv = %d\n", progname,rv); > exit(1); > } > } > > if (rv == 0) while(1) > { > sleep(60); /*60 seconds*/ > } > if (sockfd != 0) close(sockfd); > return(rv); >} > >/*end ipmi_port.c */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 429327
: 292182