bug corrected : editing a file with option -u used to fail
authorthib <thib>
Sat, 16 Dec 2000 19:01:38 +0000 (19:01 +0000)
committerthib <thib>
Sat, 16 Dec 2000 19:01:38 +0000 (19:01 +0000)
fcrontab.c

index 9e4353fe45392fc538287267ad2c9d3b82aaaee5..1ef2ef5406bd21d2ebf1af5eb7e230862aa2d5be 100644 (file)
@@ -22,7 +22,7 @@
  *  `LICENSE' that comes with the fcron source distribution.
  */
 
- /* $Id: fcrontab.c,v 1.23 2000-12-15 17:50:00 thib Exp $ */
+ /* $Id: fcrontab.c,v 1.24 2000-12-16 19:01:38 thib Exp $ */
 
 /* 
  * The goal of this program is simple : giving a user interface to fcron
@@ -42,7 +42,7 @@
 
 #include "fcrontab.h"
 
-char rcs_info[] = "$Id: fcrontab.c,v 1.23 2000-12-15 17:50:00 thib Exp $";
+char rcs_info[] = "$Id: fcrontab.c,v 1.24 2000-12-16 19:01:38 thib Exp $";
 
 void info(void);
 void usage(void);
@@ -450,12 +450,15 @@ edit_file(char *buf)
        error_e("could not fdopen");
        goto exiterr;
     }
-#if ! (defined(HAVE_SETREGID) && defined(HAVE_SETREUID))
-    if (fchown(file, asuid, asgid) != 0) {
-       error_e("Could not fchown %s to asuid and asgid", tmp);
-       goto exiterr;
-    }
+#if defined(HAVE_SETREGID) && defined(HAVE_SETREUID)
+    if (uid == 0)
+#else
+    if (1)
 #endif
+       if (fchown(file, asuid, asgid) != 0) {
+           error_e("Could not fchown %s to asuid and asgid", tmp);
+           goto exiterr;
+       }
     /* copy user's fcrontab (if any) to a temp file */
     if ( (f = fopen(buf, "r")) == NULL ) {
        if ( errno != ENOENT ) {