1 ! Copyright (C) 2008 Doug Coleman.
2 ! See https://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 corresponding to every field from the Unix passwd struct. BSD passwd structures have four extra slots: " { $snippet "change" } ", " { $snippet "class" } ", " { $snippet "expire" } ", " { $snippet "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." } ;
65 { "id/f" "an integer or f" } }
66 { $description "Returns the user id associated with the user-name." } ;
68 HELP: with-effective-user
70 { "string/id/f" "a string, a uid, or f" } { "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. If the first parameter is " { $link f } ", the quotation is called as the current user." } ;
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/f" "a string, a uid, or f" } { "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. If the first parameter is " { $link f } ", the quotation is called as the current user." } ;
84 real-user-name real-user-id set-real-user
85 effective-user-name effective-user-id
92 { "id/f" "an integer or " { $link f } }
94 { $description "Returns a group id or throws an exception." } ;
101 { $description "Returns a sequence of group names as strings." } ;
105 { "name/id" "a string or an integer" }
108 { $description "Returns a boolean representing the user's existence." } ;
110 ARTICLE: "unix.users" "Unix users"
111 "The " { $vocab-link "unix.users" } " vocabulary contains words that return information about Unix users."
114 { $subsections all-users }
115 "Listing all user names:"
116 { $subsections all-user-names }
117 "Checking if a user exists:"
118 { $subsections user-exists? }
119 "Querying/setting the current real user:"
125 "Querying/setting the current effective user:"
131 "Combinators to change users:"