-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_login.sp
executable file
·72 lines (63 loc) · 2.38 KB
/
edit_login.sp
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
#!/usr/local/bin/spar
with separate "config/contributors.inc.sp";
with separate "lib/world.inc.sp";
with separate "config/config.inc.sp";
procedure edit_login is
pragma annotate( summary, "edit_login" )
@( description, "Edit a login's details" )
@( author, "Ken O. Burtch" );
pragma license( gplv3 );
pragma software_model( shell_script );
with separate "lib/common.inc.sp";
with separate "lib/logins.inc.sp";
pragma restriction( no_external_commands );
sshd_logins_file : btree_io.file( a_sshd_login );
key : string;
login : a_sshd_login;
--cnt : natural := 0;
s : string;
begin
put( "Username? " );
key := get_line;
if key = "" then
return;
end if;
btree_io.open( sshd_logins_file, string( sshd_logins_path ), sshd_logins_buffer_width, sshd_logins_buffer_width );
btree_io.get( sshd_logins_file, key, login );
put( "Username: " ) @ ( login.username ); new_line;
put( "Count: " ) @ ( login.count ); new_line;
put( "Kind: " ) @ ( login.kind ); new_line;
put( "Existence: " ) @ ( login.existence ); new_line;
put( "Comment: " ) @ ( login.comment ); new_line;
new_line;
put_line( " 0 privileged_login, 1 service_login, 2 dictionary_login," );
put_line( " 3 UNUSED , 4 unknown_login_kind, 5 role_login," );
put_line( " 6 guest_login, 7 data_service_login, 8 calling_card" );
put_line( " 9 disabled login, 10 email alias" );
put( "New Kind? " );
s := get_line;
s := strings.trim( @ );
case s is
when "0" => login.kind := privileged_login;
when "1" => login.kind := service_login;
when "2" => login.kind := dictionary_login;
when "3" => login.kind := existing_login;
when "4" => login.kind := unknown_login_kind;
when "5" => login.kind := role_login;
when "6" => login.kind := guest_login;
when "7" => login.kind := data_service_login;
when "8" => login.kind := calling_card;
when "9" => login.kind := disabled_login;
when "10" => login.kind := email_alias_login;
when others => put_line( "I don't know that kind" );
end case;
login.comment := comment_string( strings.trim( s ) );
put( "New Reason? ('x' aborts) " );
login.comment := get_line;
login.comment := comment_string( strings.trim( @ ) );
if login.comment /= "x" then
btree_io.replace( sshd_logins_file, key, login );
end if;
btree_io.close( sshd_logins_file );
end edit_login;
-- vim: ft=spar