1 |
douglas |
562 |
// Douglas Thrift |
2 |
|
|
// |
3 |
|
|
// CCS Computer Science |
4 |
|
|
// |
5 |
|
|
// Secret Password |
6 |
|
|
|
7 |
|
|
#include <fcntl.h> |
8 |
|
|
|
9 |
|
|
#include "common.h" |
10 |
|
|
|
11 |
|
|
int main(int argc, char *argv[]) |
12 |
|
|
{ |
13 |
|
|
int exception; |
14 |
|
|
jmp_buf environment; |
15 |
|
|
|
16 |
|
|
switch (exception = setjmp(environment)) |
17 |
|
|
{ |
18 |
|
|
case 0: |
19 |
|
|
break; |
20 |
|
|
case 1: |
21 |
|
|
perror(argv[0]); |
22 |
|
|
|
23 |
|
|
return 1; |
24 |
|
|
default: |
25 |
|
|
fprintf(stderr, "%s: %s\n", argv[0], (char *)exception); |
26 |
|
|
|
27 |
|
|
return 1; |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
char password[_PASSWORD_LEN]; |
31 |
|
|
|
32 |
|
|
getpassword(password, environment); |
33 |
|
|
|
34 |
|
|
int file = check(open("/ccs/etc/secret", O_WRONLY | O_TRUNC), environment); |
35 |
|
|
|
36 |
|
|
check(write(file, password, strlen(password)), environment); |
37 |
|
|
check(close(file), environment); |
38 |
|
|
|
39 |
|
|
return 0; |
40 |
|
|
} |