]> 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)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 8 Feb 2025 06:51:06 +0000 (15:51 +0900)
Follow-up for 8b413ae4060b21ed4712fdad7eba195890740756.

(cherry picked from commit be4f4c4343f05f2b53deb326c241c6031c36c911)

meson.build

index bfc35b88e67e309257d5604a144ca5ef8c010fca..caf2af0753da629da10f9c8fb59cee845053108e 100644 (file)
@@ -692,17 +692,20 @@ endif
 
 #####################################################################
 
-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@"'
 
@@ -740,8 +743,6 @@ endif
 
 #####################################################################
 
-gperf = find_program('gperf')
-
 gperf_test_format = '''
 #include <string.h>
 const char* in_word_set(const char *, @0@);
@@ -890,11 +891,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) +
@@ -902,20 +902,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) +
@@ -923,13 +925,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