the tempfile to the permanent file using native code instead
of calling /bin/mv. Hopefully this will permanently solve the
(now rare) issue where netconfigs files disappear.
* Allow users to retrieve and store netconfigs files for their
own mailbox rooms. This will be required for configuration of
POP3 aggregation, and in the future it will be required for
RSS aggregation.
- if (CtdlAccessCheck(ac_room_aide)) return;
+ if ( (CC->room.QRflags & QR_MAILBOX) && (CC->user.usernum == atol(CC->room.QRname)) ) {
+ /* users can edit the netconfigs for their own mailbox rooms */
+ }
+ else if (CtdlAccessCheck(ac_room_aide)) return;
+
assoc_file_name(filename, sizeof filename, &CC->room, ctdl_netcfg_dir);
cprintf("%d Network settings for room #%ld <%s>\n",
LISTING_FOLLOWS,
assoc_file_name(filename, sizeof filename, &CC->room, ctdl_netcfg_dir);
cprintf("%d Network settings for room #%ld <%s>\n",
LISTING_FOLLOWS,
char tempfilename[SIZ];
char filename[SIZ];
char buf[SIZ];
char tempfilename[SIZ];
char filename[SIZ];
char buf[SIZ];
- if (CtdlAccessCheck(ac_room_aide)) return;
+ if ( (CC->room.QRflags & QR_MAILBOX) && (CC->user.usernum == atol(CC->room.QRname)) ) {
+ /* users can edit the netconfigs for their own mailbox rooms */
+ }
+ else if (CtdlAccessCheck(ac_room_aide)) return;
+
CtdlMakeTempFileName(tempfilename, sizeof tempfilename);
assoc_file_name(filename, sizeof filename, &CC->room, ctdl_netcfg_dir);
CtdlMakeTempFileName(tempfilename, sizeof tempfilename);
assoc_file_name(filename, sizeof filename, &CC->room, ctdl_netcfg_dir);
- /* Now copy the temp file to its permanent location
- * (We use /bin/mv instead of link() because they may be on
- * different filesystems)
+ /* Now copy the temp file to its permanent location.
+ * (We copy instead of link because they may be on different filesystems)
- unlink(filename);
- snprintf(buf, sizeof buf, "/bin/mv %s %s", tempfilename, filename);
begin_critical_section(S_NETCONFIGS);
begin_critical_section(S_NETCONFIGS);
+ fp = fopen(tempfilename, "r");
+ if (fp != NULL) {
+ newfp = fopen(filename, "w");
+ if (newfp != NULL) {
+ while (fgets(buf, sizeof buf, fp) != NULL) {
+ fprintf(newfp, "%s", buf);
+ }
+ fclose(newfp);
+ fclose(fp);
+ }
+ }
end_critical_section(S_NETCONFIGS);
end_critical_section(S_NETCONFIGS);