]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/uid.c
FORCE_UIDGID fixes (it compiles properly now with that enabled, but untested)
[netatalk.git] / etc / afpd / uid.c
index b38614649d25d12d7107edde6057417d5acf25b2..9287d69fccfe14b349c56796701c7eb2b52a16c1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uid.c,v 1.3 2001-02-23 22:16:15 rufustfirefly Exp $
+ * $Id: uid.c,v 1.5 2001-06-27 14:53:16 rufustfirefly Exp $
  * code: jeff@univrel.pr.uconn.edu
  *
  * These functions are abstracted here, so that all calls for resolving
@@ -9,7 +9,7 @@
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
+#endif /* HAVE_CONFIG_H */
 
 /* don't compile this file at all unless FORCE_UIDGID is set */
 #ifdef FORCE_UIDGID
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
+#endif /* HAVE_UNISTD_H */
 
 void save_uidgid ( pair )
-       uidgidset *pair;
+       uidgidset **pair;
 {
-       (pair)->uid = geteuid ();
-       (pair)->gid = getegid ();
+       /* allocate the memory */
+       pair = malloc ( sizeof ( uidgidset ) );
+
+       /* then assign the values */
+       (*pair)->uid = geteuid ();
+       (*pair)->gid = getegid ();
 } /* end function void save_uidgid ( pair ) */
 
 void restore_uidgid ( pair )
-       uidgidset *pair;
+       uidgidset **pair;
 {
-       if ( seteuid ( (pair)->uid ) < 0 )
+       if ( seteuid ( (*pair)->uid ) < 0 )
                syslog ( LOG_ERR, "restore_uidgid: unable to seteuid '%s': %m",
-                       (pair)->uid );
-       if ( setegid ( (pair)->gid ) < 0 )
+                       (*pair)->uid );
+       if ( setegid ( (*pair)->gid ) < 0 )
                syslog ( LOG_ERR, "restore_uidgid: unable to setegid '%s': %m",
-                       (pair)->gid );
+                       (*pair)->gid );
 } /* end function void restore_uidgid ( pair ) */
 
 void set_uidgid ( this_volume )
-       struct vol      *this_volume;
+       const struct vol        *this_volume;
 {
        int             uid, gid;   /* derived ones go in here */
 
@@ -71,6 +75,9 @@ int user_to_uid ( username )
 {
        struct passwd *this_passwd;
 
+       /* free memory for pointer */
+       this_passwd = malloc ( sizeof ( struct passwd ) );
+
        /* check for anything */
        if ( strlen ( username ) < 1 ) return 0;
 
@@ -90,6 +97,9 @@ int group_to_gid ( group )
 {
        struct group *this_group;
 
+       /* free memory for pointer */
+       this_group = malloc ( sizeof ( struct group ) );
+
        /* check for anything */
        if ( strlen ( group ) < 1 ) return 0;
 
@@ -104,4 +114,4 @@ int group_to_gid ( group )
 
 } /* end function int group_to_gid ( group ) */
 
-#endif FORCE_UIDGID
+#endif /* FORCE_UIDGID */