Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1154 → Rev 1155

/rebootdaemon/trunk/rebootdaemon.c
107,7 → 107,10
return -1;
}
 
listen(s, 1);
if(listen(s, 1) != 0) {
close(s);
return -1;
}
 
return s;
}
117,10 → 120,10
int t;
char cmd[CMDSIZE];
char buf[BUFSIZE];
char* msg;
int br;
struct sockaddr_in sa;
socklen_t sa_len;
int cmdlen;
 
for(;;) {
sa_len = sizeof(sa);
128,17 → 131,17
if(errno == EINTR) /* EINTR might happen on accept(), */
continue; /* try again */
 
msg = strerror(errno);
syslog(LOG_ERR, "cannot get connection, %s", msg);
syslog(LOG_ERR, "cannot get connection, %s", strerror(errno));
continue;
}
 
msg = inet_ntoa(sa.sin_addr);
syslog(LOG_INFO, "connect from %s", msg);
syslog(LOG_INFO, "connect from %s", inet_ntoa(sa.sin_addr));
 
cmd[0] = '\0';
cmdlen = 0;
while((br = recv(t, buf, BUFSIZE, 0)) > 0) {
strncat(cmd, buf, min(br, sizeof(cmd) - strlen(cmd) - 1));
strncat(cmd, buf, min(br, sizeof(cmd) - cmdlen - 1));
cmdlen += min(br, sizeof(cmd) - cmdlen - 1);
}
sleep(1);
close(t);
149,8 → 152,7
syslog(LOG_EMERG, "REBOOT");
sleep(5);
if(reboot(RB_AUTOBOOT) < 0) {
msg = strerror(errno);
syslog(LOG_ERR, "cannot reboot, %s", msg);
syslog(LOG_ERR, "cannot reboot, %s", strerror(errno));
}
}
}
255,7 → 257,8
if(++i < argc) {
strncpy(config_name, argv[i], MAX_CONFIG_LINE);
if(config_name[MAX_CONFIG_LINE - 1] != '\0')
return print_cmd_error(argc, argv, "Config file name is too long", NULL);
return print_cmd_error(argc, argv,
"Config file name is too long", NULL);
}
else {
return print_cmd_error(argc, argv, "Config file expected", NULL);