indonesian translation
[debian/amanda] / common-src / bsd-security.c
index ad2929219e93031d2b060aa15cae0391edfadacb..2d4304e64212f9909e13316c8697e2f2da33fcfb 100644 (file)
@@ -178,10 +178,8 @@ bsd_connect(
         * Only init the IPv6 socket once
         */
        if (res_addr->ai_addr->sa_family == AF_INET6 && not_init6 == 1) {
-           uid_t euid;
            dgram_zero(&netfd6.dgram);
 
-           euid = geteuid();
            set_root_privs(1);
            result_bind = dgram_bind(&netfd6.dgram,
                                     res_addr->ai_addr->sa_family, &port);
@@ -220,10 +218,8 @@ bsd_connect(
         * Only init the IPv4 socket once
         */
        if (res_addr->ai_addr->sa_family == AF_INET && not_init4 == 1) {
-           uid_t euid;
            dgram_zero(&netfd4.dgram);
 
-           euid = geteuid();
            set_root_privs(1);
            result_bind = dgram_bind(&netfd4.dgram,
                                     res_addr->ai_addr->sa_family, &port);
@@ -317,6 +313,7 @@ bsd_accept(
     void       (*fn)(security_handle_t *, pkt_t *),
     void       *datap)
 {
+    struct stat sbuf;
 
     assert(in >= 0 && out >= 0);
     assert(fn != NULL);
@@ -343,7 +340,13 @@ bsd_accept(
     netfd4.prefix_packet = &bsd_prefix_packet;
     netfd4.driver = &bsd_security_driver;
 
-    udp_addref(&netfd4, &udp_netfd_read_callback);
+    /* check if in is a socket */
+    fstat(in, &sbuf);
+    if (S_ISSOCK(sbuf.st_mode)) {
+       udp_addref(&netfd4, &udp_netfd_read_callback);
+    } else {
+       g_warning("input file descriptor is not a socket; cannot use BSD auth");
+    }
 }
 
 /*