mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-11 17:02:56 +00:00
cmd: simplify lxc-usernsexec
Calculate length only once. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
197c9293a6
commit
5ff0284480
@ -194,8 +194,9 @@ static int parse_map(char *map)
|
|||||||
* only use the first one for each of uid and gid, because otherwise we're not
|
* only use the first one for each of uid and gid, because otherwise we're not
|
||||||
* sure which entries the user wanted.
|
* sure which entries the user wanted.
|
||||||
*/
|
*/
|
||||||
static int read_default_map(char *fnam, int which, char *username)
|
static int read_default_map(char *fnam, int which, char *user)
|
||||||
{
|
{
|
||||||
|
size_t len;
|
||||||
char *p1, *p2;
|
char *p1, *p2;
|
||||||
FILE *fin;
|
FILE *fin;
|
||||||
struct id_map *newmap;
|
struct id_map *newmap;
|
||||||
@ -207,10 +208,9 @@ static int read_default_map(char *fnam, int which, char *username)
|
|||||||
if (!fin)
|
if (!fin)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
len = strlen(user);
|
||||||
while (getline(&line, &sz, fin) != -1) {
|
while (getline(&line, &sz, fin) != -1) {
|
||||||
if (sz <= strlen(username) ||
|
if (sz <= len || strncmp(line, user, len) != 0 || line[len] != ':')
|
||||||
strncmp(line, username, strlen(username)) != 0 ||
|
|
||||||
line[strlen(username)] != ':')
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
p1 = strchr(line, ':');
|
p1 = strchr(line, ':');
|
||||||
|
Loading…
Reference in New Issue
Block a user