]> gitweb.factorcode.org Git - factor.git/blob - basis/unix/users/users-docs.factor
Switch to https urls
[factor.git] / basis / unix / users / users-docs.factor
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 ;
4 IN: unix.users
5
6 HELP: all-users
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." } ;
9
10 HELP: effective-user-name
11 { $values { "string" string } }
12 { $description "Returns the effective user-name for the current user." } ;
13
14 HELP: effective-user-id
15 { $values { "id" integer } }
16 { $description "Returns the effective user-name id for the current user." } ;
17
18 HELP: new-passwd
19 { $values { "passwd" passwd } }
20 { $description "Creates a new passwd tuple dependent on the operating system." } ;
21
22 HELP: passwd
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" } "." } ;
24
25 HELP: user-cache
26 { $description "A symbol storing passwd structures indexed by user-ids when within a " { $link with-user-cache } "." } ;
27
28 HELP: passwd>new-passwd
29 { $values
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." } ;
33
34 HELP: real-user-name
35 { $values { "string" string } }
36 { $description "The real user-name of the current user." } ;
37
38 HELP: real-user-id
39 { $values { "id" integer } }
40 { $description "The real user id of the current user." } ;
41
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." } ;
45
46 HELP: set-real-user
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." } ;
49
50 HELP: user-passwd
51 { $values
52     { "obj" object }
53     { "passwd/f" "passwd or f" } }
54 { $description "Returns the passwd tuple given a user-name string or user id." } ;
55
56 HELP: user-name
57 { $values
58     { "id" integer }
59     { "string" string } }
60 { $description "Returns the user-name associated with the user id." } ;
61
62 HELP: user-id
63 { $values
64     { "string" string }
65     { "id/f" "an integer or f" } }
66 { $description "Returns the user id associated with the user-name." } ;
67
68 HELP: with-effective-user
69 { $values
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." } ;
72
73 HELP: with-user-cache
74 { $values
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." } ;
77
78 HELP: with-real-user
79 { $values
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." } ;
82
83 {
84     real-user-name real-user-id set-real-user
85     effective-user-name effective-user-id
86     set-effective-user
87 } related-words
88
89 HELP: ?user-id
90 { $values
91     { "string" string }
92     { "id/f" "an integer or " { $link f } }
93 }
94 { $description "Returns a group id or throws an exception." } ;
95
96 HELP: all-user-names
97 { $values
98
99     { "seq" sequence }
100 }
101 { $description "Returns a sequence of group names as strings." } ;
102
103 HELP: user-exists?
104 { $values
105     { "name/id" "a string or an integer" }
106     { "?" boolean }
107 }
108 { $description "Returns a boolean representing the user's existence." } ;
109
110 ARTICLE: "unix.users" "Unix users"
111 "The " { $vocab-link "unix.users" } " vocabulary contains words that return information about Unix users."
112 $nl
113 "Listing all 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:"
120 { $subsections
121     real-user-name
122     real-user-id
123     set-real-user
124 }
125 "Querying/setting the current effective user:"
126 { $subsections
127     effective-user-name
128     effective-user-id
129     set-effective-user
130 }
131 "Combinators to change users:"
132 { $subsections
133     with-real-user
134     with-effective-user
135 } ;
136
137 ABOUT: "unix.users"