Skip to content

Commit

Permalink
meson: also skip uid/gid check for nobody user/group when id command …
Browse files Browse the repository at this point in the history
…not found

Follow-up for 8b413ae.
  • Loading branch information
yuwata authored and bluca committed Feb 7, 2025
1 parent d7c86fe commit be4f4c4
Showing 1 changed file with 37 additions and 33 deletions.
70 changes: 37 additions & 33 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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@"'

Expand Down Expand Up @@ -738,8 +741,6 @@ endif

#####################################################################

gperf = find_program('gperf')

gperf_test_format = '''
#include <string.h>
const char* in_word_set(const char *, @0@);
Expand Down Expand Up @@ -889,46 +890,49 @@ 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) +
'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, 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) +
'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, 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
Expand Down

0 comments on commit be4f4c4

Please sign in to comment.