* `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"
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 */
}
-/* 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)
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 */