meson: also skip uid/gid check for nobody user/group when id command not found

Follow-up for 8b413ae406.
This commit is contained in:
Yu Watanabe
2025-02-07 11:36:46 +09:00
committed by Luca Boccassi
parent d7c86fea6b
commit be4f4c4343

View File

@@ -690,17 +690,20 @@ endforeach
#####################################################################
sh = find_program('sh')
echo = find_program('echo')
sed = find_program('sed')
awk = find_program('awk')
stat = find_program('stat')
ln = find_program('ln')
git = find_program('git', required : false)
env = find_program('env')
rsync = find_program('rsync', required : false)
diff = find_program('diff')
echo = find_program('echo')
env = find_program('env')
find = find_program('find')
getent = find_program('getent', required : false)
git = find_program('git', required : false)
gperf = find_program('gperf')
id = find_program('id', required : false)
ln = find_program('ln')
rsync = find_program('rsync', required : false)
sed = find_program('sed')
sh = find_program('sh')
stat = find_program('stat')
ln_s = ln.full_path() + ' -frsT -- "${DESTDIR:-}@0@" "${DESTDIR:-}@1@"'
@@ -738,8 +741,6 @@ endif
#####################################################################
gperf = find_program('gperf')
gperf_test_format = '''
#include <string.h>
const char* in_word_set(const char *, @0@);
@@ -889,11 +890,10 @@ nobody_user = get_option('nobody-user')
nobody_group = get_option('nobody-group')
if not meson.is_cross_build()
find_getent_result = find_program('getent', required : false)
if find_getent_result.found()
getent_result = run_command('getent', 'passwd', '65534', check : false)
if getent_result.returncode() == 0
name = getent_result.stdout().split(':')[0]
if getent.found()
ret = run_command(getent, 'passwd', '65534', check : false)
if ret.returncode() == 0
name = ret.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) +
@@ -901,20 +901,22 @@ if not meson.is_cross_build()
endif
endif
endif
id_result = run_command('id', '-u', nobody_user, check : false)
if id_result.returncode() == 0
id = id_result.stdout().strip().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.')
if id.found()
ret = run_command(id, '-u', nobody_user, check : false)
if ret.returncode() == 0
uid = ret.stdout().strip().to_int()
if uid != 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, uid) +
'Your build will result in an user table setup that is incompatible with the local system.')
endif
endif
endif
if find_getent_result.found()
getent_result = run_command('getent', 'group', '65534', check : false)
if getent_result.returncode() == 0
name = getent_result.stdout().split(':')[0]
if getent.found()
ret = run_command(getent, 'group', '65534', check : false)
if ret.returncode() == 0
name = ret.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) +
@@ -922,13 +924,15 @@ if not meson.is_cross_build()
endif
endif
endif
id_result = run_command('id', '-g', nobody_group, check : false)
if id_result.returncode() == 0
id = id_result.stdout().strip().to_int()
if id != 65534
warning('\n' +
'The local group with the configured group name "@0@" of the nobody group does not have GID 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.')
if id.found()
ret = run_command(id, '-g', nobody_group, check : false)
if ret.returncode() == 0
gid = ret.stdout().strip().to_int()
if gid != 65534
warning('\n' +
'The local group with the configured group name "@0@" of the nobody group does not have GID 65534 (it has @1@).\n'.format(nobody_group, gid) +
'Your build will result in an group table setup that is incompatible with the local system.')
endif
endif
endif
endif