summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sade/config.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>2001-03-13 06:42:12 +0000
committerjkh <jkh@FreeBSD.org>2001-03-13 06:42:12 +0000
commit128a8b62a8b501fba6ad862b9a13141933fb21e5 (patch)
tree47f35d6989a8d531aa43c2febc7fdb80e694c84d /usr.sbin/sade/config.c
parent9a4f9ead36389b3d59ae1fe26f08459a2c42e41b (diff)
downloadFreeBSD-src-128a8b62a8b501fba6ad862b9a13141933fb21e5.zip
FreeBSD-src-128a8b62a8b501fba6ad862b9a13141933fb21e5.tar.gz
Be a better rc.conf citizen and create an initial file which:
1. Has a time-stamp to show when it was created 2. Sorts and uniq's the output to only contain single instances of a given setting. This doesn't mean you still can't have settings which override one another, that's still possible since it's too much trouble to do the redundancy checking here. Requested by: lots of people
Diffstat (limited to 'usr.sbin/sade/config.c')
-rw-r--r--usr.sbin/sade/config.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c
index 3a5f9df..7a651dc 100644
--- a/usr.sbin/sade/config.c
+++ b/usr.sbin/sade/config.c
@@ -44,6 +44,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <sys/mount.h>
+#include <time.h>
static Chunk *chunk_list[MAX_CHUNKS];
static int nchunks;
@@ -378,6 +379,8 @@ configRC_conf(void)
FILE *rcSite;
Variable *v;
int write_header;
+ time_t t_loc;
+ char *cp;
static int did_marker = 0;
write_header = !file_readable("/etc/rc.conf");
@@ -388,6 +391,8 @@ configRC_conf(void)
fprintf(rcSite, "# This file now contains just the overrides from /etc/defaults/rc.conf\n");
fprintf(rcSite, "# please make all changes to this file.\n\n");
fprintf(rcSite, "# Enable network daemons for user convenience.\n");
+ if ((t_loc = time(NULL)) != -1 && (cp = ctime(&t_loc)))
+ fprintf(rcSite, "# Created: %s", cp);
}
/* Now do variable substitutions */
@@ -402,6 +407,10 @@ configRC_conf(void)
}
}
fclose(rcSite);
+ /* Tidy up the resulting file if it's late enough in the installation
+ for sort and uniq to be available */
+ if (file_readable("/usr/bin/sort") && file_readable("/usr/bin/uniq"))
+ (void)vsystem("sort /etc/rc.conf | uniq > /etc/rc.conf.new && mv /etc/rc.conf.new /etc/rc.conf");
}
int
OpenPOWER on IntegriCloud