mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: take 8 and 9 as hex digits in an \x escape
An f or w entry with \x39 in the argument writes the byte 3 followed
by a 9, where it should write a 9:
f /tmp/file - - - - \x39
write_hex() only takes the digits 0 to 7, as for an octal escape.
Take all hex digits.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
3 files changed
+12
-3
No files matched your search
@@ -315,6 +315,8 @@ All relevant changes are documented in this file.
|
|||||||
- Fix age `0` in a tmpfiles entry, it was read as no age. As in
|
- Fix age `0` in a tmpfiles entry, it was read as no age. As in
|
||||||
tmpfiles.d(5), `tmpfiles --clean` now empties the directory of such an
|
tmpfiles.d(5), `tmpfiles --clean` now empties the directory of such an
|
||||||
entry
|
entry
|
||||||
|
- Fix `\x` escapes with the digits 8 or 9 in the argument of a tmpfiles
|
||||||
|
entry, `\x39` was written as the byte 3 and a `9`
|
||||||
- Fix logins refused after boot on a system with systemd's tmpfiles.d
|
- Fix logins refused after boot on a system with systemd's tmpfiles.d
|
||||||
files installed. They create `/run/nologin` at boot, and on systemd it
|
files installed. They create `/run/nologin` at boot, and on systemd it
|
||||||
is removed by systemd-user-sessions. Finit now removes it when leaving
|
is removed by systemd-user-sessions. Finit now removes it when leaving
|
||||||
|
|||||||
+2
-3
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "config.h" /* Generated by configure script */
|
#include "config.h" /* Generated by configure script */
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -190,9 +191,7 @@ static char *write_hex(FILE *fp, char *p)
|
|||||||
for (i = 0; p[i] && len < 2; i++) {
|
for (i = 0; p[i] && len < 2; i++) {
|
||||||
char c = p[i];
|
char c = p[i];
|
||||||
|
|
||||||
if ((c >= '0' && c <= '7') ||
|
if (isxdigit((unsigned char)c))
|
||||||
(c >= 'a' && c <= 'f') ||
|
|
||||||
(c >= 'A' && c <= 'F'))
|
|
||||||
num[len++] = c;
|
num[len++] = c;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -64,3 +64,11 @@ CONF
|
|||||||
run "/libexec/finit/tmpfiles --create $CONF"
|
run "/libexec/finit/tmpfiles --create $CONF"
|
||||||
assert "First match" "$(texec cat $DIR/w1 | tr '\n' ' ')" = "one two"
|
assert "First match" "$(texec cat $DIR/w1 | tr '\n' ' ')" = "one two"
|
||||||
assert "Second match" "$(texec cat $DIR/w2 | tr '\n' ' ')" = "one two"
|
assert "Second match" "$(texec cat $DIR/w2 | tr '\n' ' ')" = "one two"
|
||||||
|
|
||||||
|
sep
|
||||||
|
say 'Escapes in the argument'
|
||||||
|
run "cat > $CONF" <<'CONF'
|
||||||
|
f /tmp/arg/hex - - - - \x39\x41\x4a\x6b
|
||||||
|
CONF
|
||||||
|
run "/libexec/finit/tmpfiles --create $CONF"
|
||||||
|
assert "All hex digits" "$(texec cat $DIR/hex)" = "9AJk"
|
||||||
Reference in new issue
Block a user