From 0204199cc95ea215abcc93897f0edbe5cc62d5f7 Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Mon, 21 Jan 2008 20:03:56 +0000 Subject: actually prune out partial notdef'd acl writing code --- server/acl_files.c | 134 ----------------------------------------------------- 1 file changed, 134 deletions(-) (limited to 'server/acl_files.c') diff --git a/server/acl_files.c b/server/acl_files.c index 239bb20..fbf0d71 100644 --- a/server/acl_files.c +++ b/server/acl_files.c @@ -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 -- cgit v1.2.3