diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/main.c b/src/main.c index 31d8aec..c36bc9a 100644 --- a/src/main.c +++ b/src/main.c @@ -176,7 +176,7 @@ int main(int argc, char **argv) { if (daemon(1, 0)) { syslog(LOG_ERR, "failed to daemonize: %s", strerror(errno)); retme = -1; - goto nbd_nbtpd_cleanup_main; + goto cleanup; } else { syslog(LOG_INFO, "daemonized"); } @@ -185,7 +185,7 @@ int main(int argc, char **argv) { if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0) { syslog(LOG_ERR, "unable to set socket timeout: %s", strerror(errno)); retme = -1; - goto nbd_nbtpd_cleanup_main; + goto cleanup; } struct sockaddr_in saddr; saddr.sin_family = AF_INET; @@ -194,7 +194,7 @@ int main(int argc, char **argv) { if (bind(s, (struct sockaddr*)&saddr, sizeof(saddr)) < 0) { syslog(LOG_ERR, "socket bind failed: %s", strerror(errno)); retme = -1; - goto nbd_nbtpd_cleanup_main; + goto cleanup; } syslog(LOG_INFO, "socket bind success"); if (daemonize) { @@ -207,7 +207,7 @@ int main(int argc, char **argv) { strerror(errno) ); retme = -1; - goto nbd_nbtpd_cleanup_main; + goto cleanup; } struct passwd *u = getpwnam((const char *)&user); if (setuid((*u).pw_uid) == -1) { @@ -217,14 +217,17 @@ int main(int argc, char **argv) { strerror(errno) ); retme = -1; - goto nbd_nbtpd_cleanup_main; + goto cleanup; } } +#ifdef __illumos__ + //TODO: illumos priv.h privdrop +#endif buf = malloc(1024); if (buf == NULL) { syslog(LOG_CRIT, "unable to allocate memory: %s", strerror(errno)); retme = -1; - goto nbd_nbtpd_cleanup_main; + goto cleanup; } while (!nbtpd_stop) { struct sockaddr_in caddr; @@ -300,9 +303,10 @@ int main(int argc, char **argv) { free(args); } } -nbd_nbtpd_cleanup_main: +cleanup: free(buf); close(s); pthread_exit(NULL); return retme; } + |