1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax io.streams.string kernel quotations sequences strings math ;
7 { $values { "seq" sequence } }
8 { $description "Returns a sequence of high-level " { $link passwd } " tuples that are platform-dependent and field for field complete with the Unix " { $link passwd } " structure." } ;
10 HELP: effective-user-name
11 { $values { "string" string } }
12 { $description "Returns the effective user-name for the current user." } ;
14 HELP: effective-user-id
15 { $values { "id" integer } }
16 { $description "Returns the effective user-name id for the current user." } ;
19 { $values { "passwd" passwd } }
20 { $description "Creates a new passwd tuple dependent on the operating system." } ;
23 { $description "A platform-specific tuple correspding to every field from the Unix passwd struct. BSD passwd structures have four extra slots: " { $slot "change" } ", " { $slot "class" } "," { $slot "expire" } ", " { $slot "fields" } "." } ;
26 { $description "A symbol storing passwd structures indexed by user-ids when within a " { $link with-user-cache } "." } ;
28 HELP: passwd>new-passwd
30 { "passwd" "a passwd struct" }
31 { "new-passwd" "a passwd tuple" } }
32 { $description "A platform-specific conversion routine from a passwd structure to a passwd tuple." } ;
35 { $values { "string" string } }
36 { $description "The real user-name of the current user." } ;
39 { $values { "id" integer } }
40 { $description "The real user id of the current user." } ;
42 HELP: set-effective-user
43 { $values { "string/id" "a string or a user id" } }
44 { $description "Sets the current effective user given a user-name or a user id." } ;
47 { $values { "string/id" "a string or a user id" } }
48 { $description "Sets the current real user given a user-name or a user id." } ;
53 { "passwd/f" "passwd or f" } }
54 { $description "Returns the passwd tuple given a user-name string or user id." } ;
60 { $description "Returns the user-name associated with the user id." } ;
66 { $description "Returns the user id associated with the user-name." } ;
68 HELP: with-effective-user
70 { "string/id" "a string or a uid" } { "quot" quotation } }
71 { $description "Sets the effective user-name and calls the quotation. Restores the current user-name on success or on error after the call." } ;
75 { "quot" quotation } }
76 { $description "Iterates over the password file using library calls and creates a cache in the " { $link user-cache } " symbol. The cache is a hashtable indexed by user id. When looking up many users, this approach is much faster than calling system calls." } ;
80 { "string/id" "a string or a uid" } { "quot" quotation } }
81 { $description "Sets the real user-name and calls the quotation. Restores the current user-name on success or on error after the call." } ;
84 real-user-name real-user-id set-real-user
85 effective-user-name effective-user-id
89 ARTICLE: "unix.users" "Unix users"
90 "The " { $vocab-link "unix.users" } " vocabulary contains words that return information about Unix users."
93 { $subsection all-users }
95 { $subsection real-user-name }
96 { $subsection real-user-id }
97 { $subsection set-real-user }
99 { $subsection effective-user-name }
100 { $subsection effective-user-id }
101 { $subsection set-effective-user }
102 "Combinators to change users:"
103 { $subsection with-real-user }
104 { $subsection with-effective-user } ;