mirror of
https://github.com/sheumann/hush.git
synced 2025-01-15 18:30:43 +00:00
- strndupa is a GNU extension. Using strdup to avoid several errors like:
util-linux/mdev.c:(.text+0x29a): undefined reference to `strndupa'
This commit is contained in:
parent
bb98db2ed2
commit
bb0baed564
@ -90,7 +90,7 @@ static void make_device(char *path, int delete)
|
|||||||
if (field == 0) {
|
if (field == 0) {
|
||||||
/* Regex to match this device */
|
/* Regex to match this device */
|
||||||
|
|
||||||
char *regex = strndupa(pos, end2-pos);
|
char *regex = xstrndup(pos, end2-pos);
|
||||||
regex_t match;
|
regex_t match;
|
||||||
regmatch_t off;
|
regmatch_t off;
|
||||||
int result;
|
int result;
|
||||||
@ -99,6 +99,7 @@ static void make_device(char *path, int delete)
|
|||||||
xregcomp(&match,regex, REG_EXTENDED);
|
xregcomp(&match,regex, REG_EXTENDED);
|
||||||
result = regexec(&match, device_name, 1, &off, 0);
|
result = regexec(&match, device_name, 1, &off, 0);
|
||||||
regfree(&match);
|
regfree(&match);
|
||||||
|
free(regex);
|
||||||
|
|
||||||
/* If not this device, skip rest of line */
|
/* If not this device, skip rest of line */
|
||||||
if (result || off.rm_so
|
if (result || off.rm_so
|
||||||
@ -119,7 +120,9 @@ static void make_device(char *path, int delete)
|
|||||||
uid = strtoul(pos, &s2, 10);
|
uid = strtoul(pos, &s2, 10);
|
||||||
if (s != s2) {
|
if (s != s2) {
|
||||||
struct passwd *pass;
|
struct passwd *pass;
|
||||||
pass = getpwnam(strndupa(pos, s-pos));
|
char *_unam = xstrndup(pos, s-pos);
|
||||||
|
pass = getpwnam(_unam);
|
||||||
|
free(_unam);
|
||||||
if (!pass) break;
|
if (!pass) break;
|
||||||
uid = pass->pw_uid;
|
uid = pass->pw_uid;
|
||||||
}
|
}
|
||||||
@ -128,7 +131,9 @@ static void make_device(char *path, int delete)
|
|||||||
gid = strtoul(s, &s2, 10);
|
gid = strtoul(s, &s2, 10);
|
||||||
if (end2 != s2) {
|
if (end2 != s2) {
|
||||||
struct group *grp;
|
struct group *grp;
|
||||||
grp = getgrnam(strndupa(s, end2-s));
|
char *_grnam = xstrndup(s, end2-s);
|
||||||
|
grp = getgrnam(_grnam);
|
||||||
|
free(_grnam);
|
||||||
if (!grp) break;
|
if (!grp) break;
|
||||||
gid = grp->gr_gid;
|
gid = grp->gr_gid;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user