Fix the pwd and group functions. The bb_ stuff was a leftover from
[oweals/busybox.git] / hostname.c
index 44d529c83fc287e2625fc658bdbe5b282d6b61fc..a789fa0f15d9a787691ae286db52f38bf3b3e63b 100644 (file)
@@ -1,6 +1,6 @@
 /* vi: set sw=4 ts=4: */
 /*
- * $Id: hostname.c,v 1.15 2000/10/12 22:30:31 andersen Exp $
+ * $Id: hostname.c,v 1.21 2001/01/27 08:24:37 andersen Exp $
  * Mini hostname implementation for busybox
  *
  * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -28,6 +28,7 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <unistd.h>
+#include <string.h>
 #include <stdio.h>
 
 void do_sethostname(char *s, int isfile)
@@ -40,10 +41,9 @@ void do_sethostname(char *s, int isfile)
        if (!isfile) {
                if (sethostname(s, strlen(s)) < 0) {
                        if (errno == EPERM)
-                               errorMsg("you must be root to change the hostname\n");
+                               error_msg_and_die("you must be root to change the hostname\n");
                        else
-                               perror("sethostname");
-                       exit(1);
+                               perror_msg_and_die("sethostname");
                }
        } else {
                f = xfopen(s, "r");
@@ -51,10 +51,8 @@ void do_sethostname(char *s, int isfile)
                fclose(f);
                if (buf[strlen(buf) - 1] == '\n')
                        buf[strlen(buf) - 1] = 0;
-               if (sethostname(buf, strlen(buf)) < 0) {
-                       perror("sethostname");
-                       exit(1);
-               }
+               if (sethostname(buf, strlen(buf)) < 0)
+                       perror_msg_and_die("sethostname");
        }
 }