]> asedeno.scripts.mit.edu Git - 1ts-debian.git/commitdiff
actually prune out partial notdef'd acl writing code
authorkcr <kcr@cbed1d16-5ef5-0310-b6a1-d4a37b08ba1f>
Mon, 21 Jan 2008 20:03:56 +0000 (20:03 +0000)
committerkcr <kcr@cbed1d16-5ef5-0310-b6a1-d4a37b08ba1f>
Mon, 21 Jan 2008 20:03:56 +0000 (20:03 +0000)
git-svn-id: svn://svn.1ts.org/debian/branches/zephyr-reloaded@275 cbed1d16-5ef5-0310-b6a1-d4a37b08ba1f

zephyr/server/acl_files.c

index 239bb206e69953798cf66516723c05eab4185bdf..fbf0d71ff4e42222942c564fbc5641c033734bd9 100644 (file)
@@ -11,7 +11,6 @@
  */
 
 /* Define this if you really want the ACL-writing code included.  */
-/* #define WRITE_ACL */
 
 /*
  * Stolen from lib/acl_files.c because acl_load needs to be externally
@@ -115,139 +114,6 @@ void acl_canonicalize_principal(char *principal,
 #endif
 }
 
-#ifdef notdef
-/* Get a lock to modify acl_file */
-/* Return new FILE pointer */
-/* or NULL if file cannot be modified */
-/* REQUIRES WRITE PERMISSION TO CONTAINING DIRECTORY */
-static FILE *acl_lock_file(acl_file)
-    char *acl_file;
-{
-    struct stat s;
-    char new[LINESIZE];
-    int nfd;
-    FILE *nf;
-    int mode;
-
-    if (stat(acl_file, &s) < 0) return(NULL);
-    mode = s.st_mode;
-    sprintf(new, NEW_FILE, acl_file);
-    for (;;) {
-       /* Open the new file */
-       if ((nfd = open(new, O_WRONLY|O_CREAT|O_EXCL, mode)) < 0) {
-           if (errno == EEXIST) {
-               /* Maybe somebody got here already, maybe it's just old */
-               if (stat(new, &s) < 0) return(NULL);
-               if (time(0) - s.st_ctime > WAIT_TIME) {
-                   /* File is stale, kill it */
-                   unlink(new);
-                   continue;
-               } else {
-                   /* Wait and try again */
-                   sleep(1);
-                   continue;
-               }
-           } else {
-               /* Some other error, we lose */
-               return(NULL);
-           }
-       }
-
-       /* If we got to here, the lock file is ours and ok */
-       /* Reopen it under stdio */
-       if ((nf = fdopen(nfd, "w")) == NULL) {
-           /* Oops, clean up */
-           unlink(new);
-       }
-       return(nf);
-    }
-}
-
-/* Commit changes to acl_file written onto FILE *f */
-/* Returns zero if successful */
-/* Returns > 0 if lock was broken */
-/* Returns < 0 if some other error occurs */
-/* Closes f */
-static int acl_commit(acl_file, f)
-    char *acl_file;
-    FILE *f;     
-{
-#ifdef WRITE_ACL
-    char new[LINESIZE];
-    int ret;
-    struct stat s;
-
-    sprintf(new, NEW_FILE, acl_file);
-    if (fflush(f) < 0
-       || fstat(fileno(f), &s) < 0
-       || s.st_nlink == 0) {
-       acl_abort(acl_file, f);
-       return(-1);
-    }
-
-    ret = rename(new, acl_file);
-    fclose(f);
-    return(ret);
-#else
-    abort ();
-#endif
-}
-
-/* Abort changes to acl_file written onto FILE *f */
-/* Returns 0 if successful, < 0 otherwise */
-/* Closes f */
-static int acl_abort(acl_file, f)
-    char *acl_file;
-    FILE *f;
-{
-#ifdef WRITE_ACL
-    char new[LINESIZE];
-    int ret;
-    struct stat s;
-
-    /* make sure we aren't nuking someone else's file */
-    if (fstat(fileno(f), &s) < 0 || s.st_nlink == 0) {
-       fclose(f);
-       return(-1);
-    } else {
-       sprintf(new, NEW_FILE, acl_file);
-       ret = unlink(new);
-       fclose(f);
-       return(ret);
-    }
-#else
-    abort ();
-#endif
-}
-
-/* Initialize an acl_file */
-/* Creates the file with permissions perm if it does not exist */
-/* Erases it if it does */
-/* Returns return value of acl_commit */
-int
-acl_initialize(acl_file, perm)
-    char *acl_file;
-    int perm;
-{
-    FILE *new;
-    int fd;
-
-    /* Check if the file exists already */
-    if ((new = acl_lock_file(acl_file)) != NULL) {
-       return(acl_commit(acl_file, new));
-    } else {
-       /* File must be readable and writable by owner */
-       if ((fd = open(acl_file, O_CREAT|O_EXCL, perm|0600)) < 0) {
-           return(-1);
-       } else {
-           close(fd);
-           return(0);
-       }
-    }
-}
-
-#endif /* notdef */
-
 /* Eliminate all whitespace character in buf */
 /* Modifies its argument */
 static void