]> granicus.if.org Git - fcron/commitdiff
moved save_one_file() from conf.c, fileconf.c and convert-fcrontab.c to a
authorthib <thib>
Sun, 17 Nov 2002 13:13:46 +0000 (13:13 +0000)
committerthib <thib>
Sun, 17 Nov 2002 13:13:46 +0000 (13:13 +0000)
unique function in save.c

conf.c

diff --git a/conf.c b/conf.c
index 69a3f1b7097d2b6d7e49bd9a8cad81895f10f121..461d5353b82561502a3fa2a20daf08d922f50bde 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -22,7 +22,7 @@
  *  `LICENSE' that comes with the fcron source distribution.
  */
 
- /* $Id: conf.c,v 1.63 2002-11-02 19:34:55 thib Exp $ */
+ /* $Id: conf.c,v 1.64 2002-11-17 13:13:46 thib Exp $ */
 
 #include "fcron.h"
 
@@ -35,7 +35,6 @@ int add_line_to_file(cl_t *cl, cf_t *cf, uid_t runas, char *runas_str,
 int read_strn(int fd, char **str, short int size);
 int read_type(int fd, short int *type, short int *size);
 void synchronize_file(char *file_name);
-int save_one_file(cf_t *file, char *filename);
 
 
 /* this is used to create a list of files to remove, to add */
@@ -972,42 +971,6 @@ delete_file(const char *user_name)
 
 }
 
-/* this function is called in save.c */
-int
-save_one_file(cf_t *file, char *filename)
-/* save a given file to disk */
-{
-    int fd;
-
-    /* open file */
-    fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, S_IRUSR|S_IWUSR);
-    if ( fd == -1 ) {
-       error_e("Could not open %s", file->cf_user);
-       return ERR;
-    }
-    else {
-
-       /* chown the file to root:root : this file should only be read and
-        * modified by fcron (not fcrontab) */
-       if (fchown(fd, ROOTUID, ROOTGID) != 0) {
-           error_e("Could not fchown \"%s\"", file->cf_user);
-           close(fd);
-           return ERR;
-       }
-       else {
-           /* save file : */
-           if ( write_file_to_disk(fd, file, now) == ERR ) {
-               close(fd);
-               remove(file->cf_user);
-               return ERR;
-           }
-           else
-               close(fd);
-       }
-    }
-
-    return OK;
-}
 
 void
 save_file(cf_t *arg_file)
@@ -1028,7 +991,9 @@ save_file(cf_t *arg_file)
        debug("Saving %s...", file->cf_user);
 
        /* save the file safely : save it to a temporary name, then rename() it */
-       save_file_safe(file, file->cf_user, "fcron");
+       /* chown the file to root:root : this file should only be read and
+        * modified by fcron (not fcrontab) */
+       save_file_safe(file, file->cf_user, "fcron", ROOTUID, ROOTGID, now);
 
        if (arg_file != NULL)
            /* we have to save only a single file */