summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-06-07 05:42:40 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-06-07 05:42:40 +0800
commit223f3276b226eaf9c4cec80a208e74e7434e615a (patch)
tree52dbc9b3fb1184e51aee914b01d891c06ea3db41
parente8fc08b9800ba86163e5bf43469cdc9f4b478b13 (diff)
downloadpttbbs-223f3276b226eaf9c4cec80a208e74e7434e615a.tar
pttbbs-223f3276b226eaf9c4cec80a208e74e7434e615a.tar.gz
pttbbs-223f3276b226eaf9c4cec80a208e74e7434e615a.tar.bz2
pttbbs-223f3276b226eaf9c4cec80a208e74e7434e615a.tar.lz
pttbbs-223f3276b226eaf9c4cec80a208e74e7434e615a.tar.xz
pttbbs-223f3276b226eaf9c4cec80a208e74e7434e615a.tar.zst
pttbbs-223f3276b226eaf9c4cec80a208e74e7434e615a.zip
first commit
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@297 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--util/splitpasswd.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/util/splitpasswd.c b/util/splitpasswd.c
new file mode 100644
index 00000000..1a800f6c
--- /dev/null
+++ b/util/splitpasswd.c
@@ -0,0 +1,32 @@
+#include "bbs.h"
+#include <err.h>
+
+int main(int argc, char **argv)
+{
+ userec_t xuser;
+ int fd, ufd;
+ char path[80], fn[80];
+
+ chdir(BBSHOME);
+ if( (fd = open(".PASSWDS", O_RDONLY)) < 0 )
+ err(1, ".PASSWDS");
+
+ while( read(fd, &xuser, sizeof(xuser)) > 0 ){
+ if( strcmp(xuser.userid, "in2") != 0 )
+ continue;
+ sprintf(path, "home/%c/%s", xuser.userid[0], xuser.userid);
+ if( access(path, 0) < 0 ){
+ printf("user home error (%s) (%s)\n", xuser.userid, path);
+ continue;
+ }
+ sprintf(fn, "%s/.passwd", path);
+ if( (ufd = open(fn, O_WRONLY | O_CREAT, 0600)) < 0 ){
+ perror(path);
+ continue;
+ }
+ write(ufd, &xuser, sizeof(xuser));
+ close(ufd);
+ }
+
+ return 0;
+}