about summary refs log tree commit diff stats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/main.c b/src/main.c
index ee5a912..3701c79 100644
--- a/src/main.c
+++ b/src/main.c
@@ -25,16 +25,16 @@ void stop_handler() {
 	return;
 }
 
-void usage(char* name) {
-	printf("USAGE: %s -d -u nobody -g nobody -a 127.0.0.1 -p 69 -t 128\n", name);
-	printf("\td: daemonize\n");
-	printf("\tu: username to run as (default: nobody)\n");
-	printf("\tg: group to run as (default: nobody)\n");
+void usage(char *name) {
+	printf("USAGE: %s -d -u nobody -g nobody -a 127.0.0.1 -p 69\n", name);
+	printf("\td: daemonize.\n");
+	printf("\tu: username to run as (default: nobody).  Must be specified after -d.\n");
+	printf("\tg: group to run as (default: nobody).  Must be specified after -d.\n");
 	printf("\ta: address to bind to (default: 127.0.0.1)\n");
 	printf("\tp: port to bind to (default: 69)\n");
 }
 
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
 	int daemonize = 0;
 	char addr[16], user[32], group[32];
 	memset(addr, '\0', sizeof(addr));
@@ -80,7 +80,7 @@ int main(int argc, char** argv) {
 					return -1;
 				}
 				break;
-			case '?': case 'h':
+			 case 'h': case '?':
 				usage(argv[0]);
 				return -1;
 		}
@@ -128,22 +128,22 @@ int main(int argc, char** argv) {
 	syslog(LOG_INFO, "socket bind success");
 
 	//TODO: use getpwnam_r() and getgrnam_r()
-	struct passwd u = getpwnam(&user);
-	struct group g = getgrnam(&group);
-	if (setuid(u.pw_uid) == -1) {
-		syslog(LOG_ERR, "failed to drop privileges");
+	struct passwd *u = getpwnam((const char *)&user);
+	if (setuid((*u).pw_uid) == -1) {
+		syslog(LOG_ERR, "failed to drop user privileges");
 		return -1;
 	}
-	if (setgit(g.gr_gid) == -1) {
-		syslog(LOG_ERR, "failed to drop privileges");
+	struct group *g = getgrnam((const char *)&group);
+	if (setgid((*g).gr_gid) == -1) {
+		syslog(LOG_ERR, "failed to drop group privileges");
 		return -1;
 	}
 
 	// create persistent buffer
-	char* buf;
+	char *buf;
 	buf = malloc(1024);
 	if (buf == NULL) {
-		syslog(LOG_PANIC, "unable to allocate memory!");
+		syslog(LOG_CRIT, "unable to allocate memory!");
 		close(s);
 		return -1;
 	}
@@ -160,7 +160,7 @@ int main(int argc, char** argv) {
 		//TODO: process packet
 
 		// we will never actually join on this thread, and don't care to keep it around.
-		pthread_t* _thread;
+		//pthread_t *_thread; // since this hasn't been implemented yet, clang is complaining
 
 	}