forked from joakimmelin/sklaffkom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsklaffacct.c
More file actions
114 lines (108 loc) · 3.21 KB
/
Copy pathsklaffacct.c
File metadata and controls
114 lines (108 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* sklaffacct.c */
/*
* SklaffKOM, a simple conference system for UNIX.
*
* Copyright (C) 1993-1994 Torbj|rn B}}th, Peter Forsberg, Peter Lindberg,
* Odd Petersson, Carl Sundbom
*
* Program dedicated to the memory of Staffan Bergstr|m.
*
* For questions about this program, mail sklaff@sklaffkom.se
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "sklaff.h"
#include "ext_globals.h"
#include <sys/wait.h>
#include <pwd.h>
#include <fcntl.h>
#include "globals.h"
int
main(int argc, char *argv[])
{
LINE name, login, passwd, inet, tele, cmdline, fname;
HUGE_LINE outbuf;
int fd;
char *buf;
struct passwd *pw;
tty_raw();
if ((fd = open_file(ACCT_FILE, OPEN_QUIET)) == -1) {
goto cont;
}
if ((buf = read_file(fd)) == NULL) {
goto cont;
}
close_file(fd);
output("\n%s\n", buf);
free(buf);
cont:
output(MSG_INNAME);
input("", name, LINE_LEN, 0, 0, 0);
errlogin:
output(MSG_INLOGIN);
input("", login, 11, 0, 0, 0);
pw = getpwnam(login);
if (pw != NULL) {
output("\n%s\n\n", MSG_UIDINUSE);
goto errlogin;
}
output(MSG_INPASSWD);
input("", passwd, 13, 0, 0, 0);
output(MSG_INMODEM);
input(MSG_YES, inet, 7, 0, 0, 0);
output(MSG_INTELE);
input("", tele, 70, 0, 0, 0);
output("\n");
strcpy(outbuf, "\n");
strcpy(outbuf, "------------------------------------------------\n");
strcat(outbuf, MSG_ACCAPP);
time_string(time(0), cmdline, 1);
strcat(outbuf, cmdline);
strcat(outbuf, "\n------------------------------------------------\n");
strcat(outbuf, MSG_INSNAME);
strcat(outbuf, name);
strcat(outbuf, MSG_INSLOGIN);
strcat(outbuf, login);
strcat(outbuf, MSG_INSPASSWD);
strcat(outbuf, passwd);
strcat(outbuf, MSG_INSMODEM);
strcat(outbuf, inet);
strcat(outbuf, MSG_INSTELE);
strcat(outbuf, tele);
strcat(outbuf, "\n");
sprintf(fname, "/tmp/%d", getpid());
fd = open_file(fname, OPEN_QUIET | OPEN_CREATE);
write(fd, outbuf, strlen(outbuf));
close_file(fd);
if (fork()) {
(void) wait(&fd);
} else {
close(0);
close(1);
close(2);
(void) open(fname, O_RDONLY);
(void) open("/dev/null", O_WRONLY);
(void) dup(1);
execl(MAILPRGM, MAILPRGM, SKLAFF_ACCT, (char *) 0);
}
unlink(fname);
fd = open_file(ACCT_LOG, OPEN_QUIET | OPEN_CREATE);
lseek(fd, 0L, 2);
write(fd, outbuf, strlen(outbuf));
close_file(fd);
output(MSG_APPLIED);
tty_reset();
exit(0);
}