From: Chen Qi Date: Mon, 23 Jul 2018 06:53:09 +0000 (+0800) Subject: check nobody user/group validity only when not cross compiling X-Git-Tag: v240~924 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2484bff32bc5af4af811381393df1090d6e4586f;p=thirdparty%2Fsystemd.git check nobody user/group validity only when not cross compiling Using `getent' and `id' command in case of cross compiling does not make much sense. This is because it is the host files that are checked. Besides, in some restricted cross compilation environment, these two command may not even be available. This is to avoid host comtamination. So we should only check the validity using getent and id when not cross compiling. --- diff --git a/meson.build b/meson.build index 84656cdc7e8..a8433000d6f 100644 --- a/meson.build +++ b/meson.build @@ -689,41 +689,43 @@ substs.set('containeruidbasemax', container_uid_base_max) nobody_user = get_option('nobody-user') nobody_group = get_option('nobody-group') -getent_result = run_command('getent', 'passwd', '65534') -if getent_result.returncode() == 0 - name = getent_result.stdout().split(':')[0] - if name != nobody_user - warning('\n' + - 'The local user with the UID 65534 does not match the configured user name "@0@" of the nobody user (its name is @1@).\n'.format(nobody_user, name) + - 'Your build will result in an user table setup that is incompatible with the local system.') +if not meson.is_cross_build() + getent_result = run_command('getent', 'passwd', '65534') + if getent_result.returncode() == 0 + name = getent_result.stdout().split(':')[0] + if name != nobody_user + warning('\n' + + 'The local user with the UID 65534 does not match the configured user name "@0@" of the nobody user (its name is @1@).\n'.format(nobody_user, name) + + 'Your build will result in an user table setup that is incompatible with the local system.') + endif endif -endif -id_result = run_command('id', '-u', nobody_user) -if id_result.returncode() == 0 - id = id_result.stdout().to_int() - if id != 65534 - warning('\n' + - 'The local user with the configured user name "@0@" of the nobody user does not have UID 65534 (it has @1@).\n'.format(nobody_user, id) + - 'Your build will result in an user table setup that is incompatible with the local system.') + id_result = run_command('id', '-u', nobody_user) + if id_result.returncode() == 0 + id = id_result.stdout().to_int() + if id != 65534 + warning('\n' + + 'The local user with the configured user name "@0@" of the nobody user does not have UID 65534 (it has @1@).\n'.format(nobody_user, id) + + 'Your build will result in an user table setup that is incompatible with the local system.') + endif endif -endif -getent_result = run_command('getent', 'group', '65534') -if getent_result.returncode() == 0 - name = getent_result.stdout().split(':')[0] - if name != nobody_group - warning('\n' + - 'The local group with the GID 65534 does not match the configured group name "@0@" of the nobody group (its name is @1@).\n'.format(nobody_group, name) + - 'Your build will result in an group table setup that is incompatible with the local system.') + getent_result = run_command('getent', 'group', '65534') + if getent_result.returncode() == 0 + name = getent_result.stdout().split(':')[0] + if name != nobody_group + warning('\n' + + 'The local group with the GID 65534 does not match the configured group name "@0@" of the nobody group (its name is @1@).\n'.format(nobody_group, name) + + 'Your build will result in an group table setup that is incompatible with the local system.') + endif endif -endif -id_result = run_command('id', '-g', nobody_group) -if id_result.returncode() == 0 - id = id_result.stdout().to_int() - if id != 65534 - warning('\n' + - 'The local group with the configured group name "@0@" of the nobody group does not have UID 65534 (it has @1@).\n'.format(nobody_group, id) + - 'Your build will result in an group table setup that is incompatible with the local system.') + id_result = run_command('id', '-g', nobody_group) + if id_result.returncode() == 0 + id = id_result.stdout().to_int() + if id != 65534 + warning('\n' + + 'The local group with the configured group name "@0@" of the nobody group does not have UID 65534 (it has @1@).\n'.format(nobody_group, id) + + 'Your build will result in an group table setup that is incompatible with the local system.') + endif endif endif if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')