Skip to content

Commit ef4d177

Browse files
authored
Merge pull request #2 from Tachi107/download-docs
Refresh docs, install new HTML pages
2 parents f2673fc + 8ad80a1 commit ef4d177

9 files changed

Lines changed: 778 additions & 151 deletions

.gitignore

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
man/*.5
2-
man/*.8
3-
man/*.html
4-
bin/sysusers
5-
bin/opensysusers
6-
openrc/opensysusers.initd
1+
/man/*.1
2+
/man/*.5
3+
/man/*.8
4+
/man/*.html
5+
/bin/sysusers
6+
/bin/opensysusers
7+
/openrc/opensysusers.initd

man/Makefile

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
manfiles5 = sysusers.d.5
22
manfiles8 = systemd-sysusers.8 systemd-sysusers.service.8
3-
docfiles = sysusers.d.html systemd-sysusers.html
3+
docfiles = UIDS-GIDS.html USER_NAMES.html
44

55
xsltargs = --nonet \
66
--xinclude \
@@ -21,8 +21,34 @@ man:
2121
xsltproc $(xsltargs) custom-man.xsl sysusers.d.xml
2222

2323
doc:
24-
xsltproc $(xsltargs) -o systemd-sysusers.html custom-html.xsl systemd-sysusers.xml
25-
xsltproc $(xsltargs) -o sysusers.d.html custom-html.xsl sysusers.d.xml
24+
if command -v cmark-gfm; then \
25+
md='cmark-gfm --extension table'; \
26+
elif command -v cmark; then \
27+
md='cmark'; \
28+
else \
29+
md='markdown'; \
30+
fi; \
31+
$$md UIDS-GIDS.md > UIDS-GIDS.html; \
32+
$$md USER_NAMES.md > USER_NAMES.html
33+
34+
# Delete files because wget can't overwrite them
35+
download-docs:
36+
rm -f *.xml *.xsl
37+
if command -v wget; then \
38+
download='wget'; \
39+
elif command -v curl; then \
40+
download='curl --location --remote-name-all'; \
41+
elif command -v fetch; then \
42+
download='fetch'; \
43+
fi; \
44+
$$download \
45+
'https://github.com/systemd/systemd/raw/main/man/custom-html.xsl' \
46+
'https://github.com/systemd/systemd/raw/main/man/custom-man.xsl' \
47+
'https://github.com/systemd/systemd/raw/main/man/standard-options.xml' \
48+
'https://github.com/systemd/systemd/raw/main/man/systemd-sysusers.xml' \
49+
'https://github.com/systemd/systemd/raw/main/man/sysusers.d.xml' \
50+
'https://github.com/systemd/systemd/raw/main/docs/UIDS-GIDS.md' \
51+
'https://github.com/systemd/systemd/raw/main/docs/USER_NAMES.md'
2652

2753
clean:
2854
rm -f $(manfiles5)
@@ -56,4 +82,4 @@ ifeq ($(HAVEDOC),yes)
5682
uninstall: uninstall-doc
5783
endif
5884

59-
.PHONY: all install install-man install-doc clean
85+
.PHONY: all man doc download-docs clean install install-man install-doc uninstall-man uninstall-doc uninstall

man/UIDS-GIDS.md

Lines changed: 326 additions & 0 deletions
Large diffs are not rendered by default.

man/USER_NAMES.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
title: User/Group Name Syntax
3+
category: Users, Groups and Home Directories
4+
layout: default
5+
SPDX-License-Identifier: LGPL-2.1-or-later
6+
---
7+
8+
# User/Group Name Syntax
9+
10+
The precise set of allowed user and group names on Linux systems is weakly
11+
defined. Depending on the distribution a different set of requirements and
12+
restrictions on the syntax of user/group names are enforced — on some
13+
distributions the accepted syntax is even configurable by the administrator. In
14+
the interest of interoperability systemd enforces different rules when
15+
processing users/group defined by other subsystems and when defining users/groups
16+
itself, following the principle of "Be conservative in what you send, be
17+
liberal in what you accept". Also in the interest of interoperability systemd
18+
will enforce the same rules everywhere and not make them configurable or
19+
distribution dependent. The precise rules are described below.
20+
21+
Generally, the same rules apply for user as for group names.
22+
23+
## Other Systems
24+
25+
* On POSIX the set of [valid user
26+
names](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_437)
27+
is defined as [lower and upper case ASCII letters, digits, period,
28+
underscore, and
29+
hyphen](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_282),
30+
with the restriction that hyphen is not allowed as first character of the
31+
user name. Interestingly no size limit is declared, i.e. in neither
32+
direction, meaning that strictly speaking according to POSIX both the empty
33+
string is a valid user name as well as a string of gigabytes in length.
34+
35+
* Debian/Ubuntu based systems enforce the regular expression
36+
`^[a-z][-a-z0-9]*$`, i.e. only lower case ASCII letters, digits and
37+
hyphens. As first character only lowercase ASCII letters are allowed. This
38+
regular expression is configurable by the administrator at runtime
39+
though. This rule enforces a minimum length of one character but no maximum
40+
length.
41+
42+
* Upstream shadow-utils enforces the regular expression
43+
`^[a-z_][a-z0-9_-]*[$]$`, i.e. is similar to the Debian/Ubuntu rule, but
44+
allows underscores and hyphens, but the latter not as first character. Also,
45+
an optional trailing dollar character is permitted.
46+
47+
* Fedora/Red Hat based systems enforce the regular expression of
48+
`^[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,30}[a-zA-Z0-9_.$-]?$`, i.e. a size limit of
49+
32 characters, with upper and lower case letters, digits, underscores,
50+
hyphens and periods. No hyphen as first character though, and the last
51+
character may be a dollar character. On top of that, `.` and `..` are not
52+
allowed as user/group names.
53+
54+
* sssd is known to generate user names with embedded `@` and white-space
55+
characters, as well as non-ASCII (i.e. UTF-8) user/group names.
56+
57+
* winbindd is known to generate user/group names with embedded `\` and
58+
white-space characters, as well as non-ASCII (i.e. UTF-8) user/group names.
59+
60+
Other operating systems enforce different rules; in this documentation we'll
61+
focus on Linux systems only however, hence those are out of scope. That said,
62+
software like Samba is frequently deployed on Linux for providing compatibility
63+
with Windows systems; on such systems it might be wise to stick to user/group
64+
names also valid according to Windows rules.
65+
66+
## Rules systemd enforces
67+
68+
Distilled from the above, below are the rules systemd enforces on user/group
69+
names. An additional, common rule between both modes listed below is that empty
70+
strings are not valid user/group names.
71+
72+
Philosophically, the strict mode described below enforces an allow list of
73+
what's allowed and prohibits everything else, while the relaxed mode described
74+
below implements a deny list of what's not allowed and permits everything else.
75+
76+
### Strict mode
77+
78+
Strict user/group name syntax is enforced whenever a systemd component is used
79+
to register a user or group in the system, for example a system user/group
80+
using
81+
[`systemd-sysusers.service`](https://www.freedesktop.org/software/systemd/man/systemd-sysusers.html)
82+
or a regular user with
83+
[`systemd-homed.service`](https://www.freedesktop.org/software/systemd/man/systemd-homed.html).
84+
85+
In strict mode, only uppercase and lowercase characters are allowed, as well as
86+
digits, underscores and hyphens. The first character may not be a digit or
87+
hyphen. A size limit is enforced: the minimum of `sysconf(_SC_LOGIN_NAME_MAX)`
88+
(typically 256 on Linux; rationale: this is how POSIX suggests to detect the
89+
limit), `UT_NAMESIZE-1` (typically 31 on Linux; rationale: names longer than
90+
this cannot correctly appear in `utmp`/`wtmp` and create ambiguity with login
91+
accounting) and `NAME_MAX` (255 on Linux; rationale: user names typically
92+
appear in directory names, i.e. the home directory), thus MIN(256, 31, 255) =
93+
31.
94+
95+
Note that these rules are both more strict and more relaxed than all of the
96+
rules enforced by other systems listed above. A user/group name conforming to
97+
systemd's strict rules will not necessarily pass a test by the rules enforced
98+
by these other subsystems.
99+
100+
Written as regular expression the above is: `^[a-zA-Z_][a-zA-Z0-9_-]{0,30}$`
101+
102+
### Relaxed mode
103+
104+
Relaxed user/group name syntax is enforced whenever a systemd component accepts
105+
and makes use of user/group names registered by other (non-systemd)
106+
components of the system, for example in
107+
[`systemd-logind.service`](https://www.freedesktop.org/software/systemd/man/systemd-logind.html).
108+
109+
Relaxed syntax is also enforced by the `User=` setting in service unit files,
110+
i.e. for system services used for running services. Since these users may be
111+
registered by a variety of tools relaxed mode is used, but since the primary
112+
purpose of these users is to run a system service and thus a job for systemd a
113+
warning is shown if the specified user name does not qualify by the strict
114+
rules above.
115+
116+
* No embedded NUL bytes (rationale: handling in C must be possible and
117+
straightforward)
118+
119+
* No names consisting fully of digits (rationale: avoid confusion with numeric
120+
UID/GID specifications)
121+
122+
* Similar, no names consisting of an initial hyphen and otherwise entirely made
123+
up of digits (rationale: avoid confusion with negative, numeric UID/GID
124+
specifications, e.g. `-1`)
125+
126+
* No strings that do not qualify as valid UTF-8 (rationale: we want to be able
127+
to embed these strings in JSON, with permits only valid UTF-8 in its strings;
128+
user names using other character sets, such as JIS/Shift-JIS will cause
129+
validation errors)
130+
131+
* No control characters (i.e. characters in ASCII range 1…31; rationale: they
132+
tend to have special meaning when output on a terminal in other contexts,
133+
moreover the newline character — as a specific control character — is used as
134+
record separator in `/etc/passwd`, and hence it's crucial to avoid
135+
ambiguities here)
136+
137+
* No colon characters (rationale: it is used as field separator in `/etc/passwd`)
138+
139+
* The two strings `.` and `..` are not permitted, as these have special meaning
140+
in file system paths, and user names are frequently included in file system
141+
paths, in particular for the purpose of home directories.
142+
143+
* Similar, no slashes, as these have special meaning in file system paths
144+
145+
* No leading or trailing white-space is permitted; and hence no user/group names
146+
consisting of white-space only either (rationale: this typically indicates
147+
parsing errors, and creates confusion since not visible on screen)
148+
149+
Note that these relaxed rules are implied by the strict rules above, i.e. all
150+
user/group names accepted by the strict rules are also accepted by the relaxed
151+
rules, but not vice versa.
152+
153+
Note that this relaxed mode does not refuse a couple of very questionable
154+
syntaxes. For example it permits a leading or embedded period. A leading period
155+
is problematic because the matching home directory would typically be hidden
156+
from the user's/administrator's view. An embedded period is problematic since
157+
it creates ambiguity in traditional `chown` syntax (which is still accepted
158+
today) that uses it to separate user and group names in the command's
159+
parameter: without consulting the user/group databases it is not possible to
160+
determine if a `chown` invocation would change just the owning user or both the
161+
owning user and group. It also allows embedding `@` (which is confusing to
162+
MTAs).
163+
164+
## Common Core
165+
166+
Combining all rules listed above, user/group names that shall be considered
167+
valid in all systemd contexts and on all Linux systems should match the
168+
following regular expression (at least according to our understanding):
169+
170+
`^[a-z][a-z0-9-]{0,30}$`

man/custom-html.xsl

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
11
<?xml version='1.0'?> <!--*-nxml-*-->
2-
3-
<!--
4-
SPDX-License-Identifier: LGPL-2.1+
5-
6-
This file is part of systemd.
7-
8-
Copyright 2011 Lennart Poettering
9-
10-
systemd is free software; you can redistribute it and/or modify it
11-
under the terms of the GNU Lesser General Public License as published by
12-
the Free Software Foundation; either version 2.1 of the License, or
13-
(at your option) any later version.
14-
15-
systemd is distributed in the hope that it will be useful, but
16-
WITHOUT ANY WARRANTY; without even the implied warranty of
17-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18-
Lesser General Public License for more details.
19-
20-
You should have received a copy of the GNU Lesser General Public License
21-
along with systemd; If not, see <http://www.gnu.org/licenses/>.
22-
-->
2+
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
233

244
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
255

@@ -39,7 +19,8 @@
3919
<xsl:template match="citerefentry[not(@project)]">
4020
<a>
4121
<xsl:attribute name="href">
42-
<xsl:value-of select="refentrytitle"/><xsl:text>.html#</xsl:text>
22+
<xsl:value-of select="refentrytitle"/>
23+
<xsl:text>.html#</xsl:text>
4324
<xsl:value-of select="refentrytitle/@target"/>
4425
</xsl:attribute>
4526
<xsl:call-template name="inline.charseq"/>
@@ -49,7 +30,7 @@
4930
<xsl:template match="citerefentry[@project='man-pages'] | citerefentry[manvolnum='2'] | citerefentry[manvolnum='4']">
5031
<a>
5132
<xsl:attribute name="href">
52-
<xsl:text>http://man7.org/linux/man-pages/man</xsl:text>
33+
<xsl:text>https://man7.org/linux/man-pages/man</xsl:text>
5334
<xsl:value-of select="manvolnum"/>
5435
<xsl:text>/</xsl:text>
5536
<xsl:value-of select="refentrytitle"/>
@@ -112,6 +93,21 @@
11293
</a>
11394
</xsl:template>
11495

96+
<xsl:template match="citerefentry[@project='debian']">
97+
<a>
98+
<xsl:attribute name="href">
99+
<xsl:text>https://manpages.debian.org/unstable/</xsl:text>
100+
<xsl:value-of select="refentrytitle"/>
101+
<xsl:text>/</xsl:text>
102+
<xsl:value-of select="refentrytitle"/>
103+
<xsl:text>.</xsl:text>
104+
<xsl:value-of select="manvolnum"/>
105+
<xsl:text>.en.html</xsl:text>
106+
</xsl:attribute>
107+
<xsl:call-template name="inline.charseq"/>
108+
</a>
109+
</xsl:template>
110+
115111
<xsl:template match="citerefentry[@project='freebsd']">
116112
<a>
117113
<xsl:attribute name="href">
@@ -128,7 +124,7 @@
128124
<xsl:template match="citerefentry[@project='dbus']">
129125
<a>
130126
<xsl:attribute name="href">
131-
<xsl:text>http://dbus.freedesktop.org/doc/</xsl:text>
127+
<xsl:text>https://dbus.freedesktop.org/doc/</xsl:text>
132128
<xsl:value-of select="refentrytitle"/>
133129
<xsl:text>.</xsl:text>
134130
<xsl:value-of select="manvolnum"/>
@@ -138,6 +134,15 @@
138134
</a>
139135
</xsl:template>
140136

137+
<xsl:template match="citerefentry[@project='url']">
138+
<a>
139+
<xsl:attribute name="href">
140+
<xsl:value-of select="refentrytitle/@url"/>
141+
</xsl:attribute>
142+
<xsl:call-template name="inline.charseq"/>
143+
</a>
144+
</xsl:template>
145+
141146
<!--
142147
- helper template to do conflict resolution between various headings with the same inferred ID attribute/tag from the headerlink template
143148
- this conflict resolution is necessary to prevent malformed HTML output (multiple ID attributes with the same value)

man/custom-man.xsl

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
<?xml version='1.0'?> <!--*-nxml-*-->
22

33
<!--
4-
SPDX-License-Identifier: LGPL-2.1+
5-
6-
This file is part of systemd.
7-
8-
Copyright 2013 Zbigniew Jędrzejewski-Szmek
9-
10-
systemd is free software; you can redistribute it and/or modify it
11-
under the terms of the GNU Lesser General Public License as published by
12-
the Free Software Foundation; either version 2.1 of the License, or
13-
(at your option) any later version.
14-
15-
systemd is distributed in the hope that it will be useful, but
16-
WITHOUT ANY WARRANTY; without even the implied warranty of
17-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18-
Lesser General Public License for more details.
19-
20-
You should have received a copy of the GNU Lesser General Public License
21-
along with systemd; If not, see <http://www.gnu.org/licenses/>.
4+
SPDX-License-Identifier: LGPL-2.1-or-later
225
-->
236

247
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

0 commit comments

Comments
 (0)