Commit 9e05260
authored
Fix argv injection in _create_user and gpasswd loop (#4473)
* Fix argv injection in _create_user and gpasswd loop
Use argv list with run() instead of f-string interpolation into
SysCommand, add debug logging on failure.
* Extract _chroot_argv helper and harden user/file ops
Address svartkanin's review on #4473: factor the
['arch-chroot', '-S', str(self.target), ...] boilerplate into a
private Installer._chroot_argv() helper, and migrate the seven
existing argv-form call sites to it (useradd, gpasswd, chpasswd,
chsh, chown, snapper-create-config, grub-install).
Two related hardening tweaks while in the area:
- Raise gpasswd failure log from debug() to warn(). The group-add
loop has no return-False feedback channel for the caller, so a
silent debug() means a half-configured user looks like a
successful install.
- Add `--` end-of-options separator for useradd and chown so a
username or path starting with `-` cannot smuggle flags. The TUI
validates usernames, but parse_arguments() in models/users.py
does not, so config.json is the residual hole; this closes it
for these two sites at zero cost.1 parent d836ab0 commit 9e05260
1 file changed
Lines changed: 19 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
739 | 739 | | |
740 | 740 | | |
741 | 741 | | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
742 | 745 | | |
743 | 746 | | |
744 | 747 | | |
| |||
987 | 990 | | |
988 | 991 | | |
989 | 992 | | |
990 | | - | |
991 | | - | |
992 | | - | |
993 | | - | |
994 | | - | |
995 | | - | |
996 | | - | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
| 993 | + | |
1001 | 994 | | |
1002 | 995 | | |
1003 | 996 | | |
| |||
1336 | 1329 | | |
1337 | 1330 | | |
1338 | 1331 | | |
1339 | | - | |
1340 | | - | |
1341 | | - | |
1342 | | - | |
1343 | | - | |
1344 | | - | |
1345 | | - | |
| 1332 | + | |
1346 | 1333 | | |
1347 | 1334 | | |
1348 | 1335 | | |
| |||
1922 | 1909 | | |
1923 | 1910 | | |
1924 | 1911 | | |
1925 | | - | |
| 1912 | + | |
1926 | 1913 | | |
1927 | 1914 | | |
1928 | | - | |
| 1915 | + | |
1929 | 1916 | | |
1930 | | - | |
| 1917 | + | |
1931 | 1918 | | |
1932 | 1919 | | |
1933 | | - | |
1934 | | - | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
1935 | 1923 | | |
1936 | 1924 | | |
1937 | 1925 | | |
| |||
1942 | 1930 | | |
1943 | 1931 | | |
1944 | 1932 | | |
1945 | | - | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
1946 | 1938 | | |
1947 | 1939 | | |
1948 | 1940 | | |
| |||
1957 | 1949 | | |
1958 | 1950 | | |
1959 | 1951 | | |
1960 | | - | |
| 1952 | + | |
1961 | 1953 | | |
1962 | 1954 | | |
1963 | 1955 | | |
| |||
1969 | 1961 | | |
1970 | 1962 | | |
1971 | 1963 | | |
1972 | | - | |
| 1964 | + | |
1973 | 1965 | | |
1974 | 1966 | | |
1975 | 1967 | | |
| |||
1979 | 1971 | | |
1980 | 1972 | | |
1981 | 1973 | | |
1982 | | - | |
| 1974 | + | |
1983 | 1975 | | |
1984 | 1976 | | |
1985 | 1977 | | |
| |||
0 commit comments