mirror of
https://github.com/sheumann/hush.git
synced 2024-12-21 23:29:34 +00:00
mdev: fix a bug where we were eating argv[0] of helper
This commit is contained in:
parent
6da9b00f4f
commit
32dcc53b71
@ -18,6 +18,8 @@ mkdir mdev.testdir
|
|||||||
# We need mdev executable to be in chroot jail!
|
# We need mdev executable to be in chroot jail!
|
||||||
# (will still fail with dynamically linked one, though...)
|
# (will still fail with dynamically linked one, though...)
|
||||||
cp ../busybox mdev.testdir/mdev
|
cp ../busybox mdev.testdir/mdev
|
||||||
|
mkdir mdev.testdir/bin
|
||||||
|
cp ../busybox mdev.testdir/bin/sh 2>/dev/null # for testing cmd feature
|
||||||
mkdir mdev.testdir/etc
|
mkdir mdev.testdir/etc
|
||||||
mkdir mdev.testdir/dev
|
mkdir mdev.testdir/dev
|
||||||
mkdir -p mdev.testdir/sys/block/sda
|
mkdir -p mdev.testdir/sys/block/sda
|
||||||
@ -93,6 +95,20 @@ brw-r--r-- 1 0 0 a_sda
|
|||||||
" \
|
" \
|
||||||
"" ""
|
"" ""
|
||||||
|
|
||||||
|
# continuing to use directory structure from prev test
|
||||||
|
rm -rf mdev.testdir/dev/*
|
||||||
|
# here we complicate things by having non-matching group 1 and using %0
|
||||||
|
echo "sda 0:0 644 @echo @echo TEST" >mdev.testdir/etc/mdev.conf
|
||||||
|
testing "mdev command" \
|
||||||
|
"env - ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
||||||
|
ls -lnR mdev.testdir/dev | $FILTER_LS" \
|
||||||
|
"\
|
||||||
|
@echo TEST
|
||||||
|
mdev.testdir/dev:
|
||||||
|
brw-r--r-- 1 0 0 8,0 sda
|
||||||
|
" \
|
||||||
|
"" ""
|
||||||
|
|
||||||
# clean up
|
# clean up
|
||||||
rm -rf mdev.testdir
|
rm -rf mdev.testdir
|
||||||
|
|
||||||
|
@ -156,43 +156,45 @@ static void make_device(char *path, int delete)
|
|||||||
mode = strtoul(val, NULL, 8);
|
mode = strtoul(val, NULL, 8);
|
||||||
|
|
||||||
/* 4th field (opt): >alias */
|
/* 4th field (opt): >alias */
|
||||||
if (ENABLE_FEATURE_MDEV_RENAME) {
|
#if ENABLE_FEATURE_MDEV_RENAME
|
||||||
if (!next)
|
if (!next)
|
||||||
break;
|
break;
|
||||||
|
if (*next == '>') {
|
||||||
|
#if ENABLE_FEATURE_MDEV_RENAME_REGEXP
|
||||||
|
char *s, *p;
|
||||||
|
unsigned i, n;
|
||||||
|
|
||||||
val = next;
|
val = next;
|
||||||
next = next_field(val);
|
next = next_field(val);
|
||||||
if (*val == '>') {
|
/* substitute %1..9 with off[1..9], if any */
|
||||||
#if ENABLE_FEATURE_MDEV_RENAME_REGEXP
|
n = 0;
|
||||||
/* substitute %1..9 with off[1..9], if any */
|
s = val;
|
||||||
char *s, *p;
|
while (*s && *s++ == '%')
|
||||||
unsigned i, n;
|
n++;
|
||||||
|
|
||||||
n = 0;
|
p = alias = xzalloc(strlen(val) + n * strlen(device_name));
|
||||||
s = val;
|
s = val + 1;
|
||||||
while (*s && *s++ == '%')
|
while (*s) {
|
||||||
n++;
|
*p = *s;
|
||||||
|
if ('%' == *s) {
|
||||||
p = alias = xzalloc(strlen(val) + n * strlen(device_name));
|
i = (s[1] - '0');
|
||||||
s = val + 1;
|
if (i <= 9 && off[i].rm_so >= 0) {
|
||||||
while (*s) {
|
n = off[i].rm_eo - off[i].rm_so;
|
||||||
*p = *s;
|
strncpy(p, device_name + off[i].rm_so, n);
|
||||||
if ('%' == *s) {
|
p += n - 1;
|
||||||
i = (s[1] - '0');
|
s++;
|
||||||
if (i <= 9 && off[i].rm_so >= 0) {
|
|
||||||
n = off[i].rm_eo - off[i].rm_so;
|
|
||||||
strncpy(p, device_name + off[i].rm_so, n);
|
|
||||||
p += n - 1;
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p++;
|
|
||||||
s++;
|
|
||||||
}
|
}
|
||||||
#else
|
p++;
|
||||||
alias = xstrdup(val + 1);
|
s++;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
val = next;
|
||||||
|
next = next_field(val);
|
||||||
|
alias = xstrdup(val + 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif /* ENABLE_FEATURE_MDEV_RENAME */
|
||||||
|
|
||||||
/* The rest (opt): command to run */
|
/* The rest (opt): command to run */
|
||||||
if (!next)
|
if (!next)
|
||||||
|
Loading…
Reference in New Issue
Block a user