]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: also skip uid/gid check for nobody user/group when id command not found
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 7 Feb 2025 02:36:46 +0000 (11:36 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 7 Feb 2025 10:49:58 +0000 (10:49 +0000)
Follow-up for 8b413ae4060b21ed4712fdad7eba195890740756.

meson.build

index 61e3d11bfd9f852666f6c7ca5063e09dcc13647b..5cabf68031df4b1dc2ce24f48f275f054dd395dd 100644 (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