$NetBSD: patch-af,v 1.2 2000/07/26 03:40:54 itohy Exp $ --- skkserv/skkserv.c.orig Tue Jan 21 04:16:36 1997 +++ skkserv/skkserv.c Wed Jul 26 12:15:44 2000 @@ -132,6 +132,16 @@ int ctlterm; /* fildes for control terminal */ void reread(); +#ifdef SKKSERV_UID + gid_t gid = SKKSERV_GID; + + /* revoke privilege if any */ + if (getuid() == 0) { + setgroups(1, &gid); + setgid(SKKSERV_GID); + setuid(SKKSERV_UID); + } +#endif pgmnm = argv[0]; debug = 0; errout = stderr; @@ -200,7 +210,10 @@ fclose(stderr); /* detach child process from control terminal */ -#ifdef HAVE_TIOCNOTTY +#ifdef HAVE_SETSID + setsid(); +#else +#ifdef TIOCNOTTY if ((ctlterm = open("/dev/tty", 2)) >= 0) { ioctl(ctlterm, TIOCNOTTY, 0); close(ctlterm); @@ -215,6 +228,7 @@ signal(SIGHUP, SIG_IGN); if (fork() != 0) exit(0); #endif +#endif } else { /* debug mode */ fprintf(errout, "SKK-JISYO is %s\n", jname); fflush(errout); @@ -724,6 +738,9 @@ exit(1); } hentry = gethostbyname(hname); + if (hentry == NULL) { + fprintf(errout, "%s: WARNING: gethostbyname(%s) failed\n", pgmnm, hname); + } else { #ifdef NO_ADDR_LIST strcat(hname, ":"); strcat(hname, hentry->h_addr); @@ -736,6 +753,7 @@ strcat(hname, inet_ntoa(*(struct in_addr *)*p++)); } #endif + } strcat(hname, ": "); }