• Masami Hiramatsu's avatar
    selftests: safesetid: Check the return value of setuid/setgid · 295c4e21
    Masami Hiramatsu authored
    Check the return value of setuid() and setgid().
    This fixes the following warnings and improves test result.
    
    safesetid-test.c: In function ‘main’:
    safesetid-test.c:294:2: warning: ignoring return value of ‘setuid’, declared with attribute warn_unused_result [-Wunused-result]
      setuid(NO_POLICY_USER);
      ^~~~~~~~~~~~~~~~~~~~~~
    safesetid-test.c:295:2: warning: ignoring return value of ‘setgid’, declared with attribute warn_unused_result [-Wunused-result]
      setgid(NO_POLICY_USER);
      ^~~~~~~~~~~~~~~~~~~~~~
    safesetid-test.c:309:2: warning: ignoring return value of ‘setuid’, declared with attribute warn_unused_result [-Wunused-result]
      setuid(RESTRICTED_PARENT);
      ^~~~~~~~~~~~~~~~~~~~~~~~~
    safesetid-test.c:310:2: warning: ignoring return value of ‘setgid’, declared with attribute warn_unused_result [-Wunused-result]
      setgid(RESTRICTED_PARENT);
      ^~~~~~~~~~~~~~~~~~~~~~~~~
    safesetid-test.c: In function ‘test_setuid’:
    safesetid-test.c:216:3: warning: ignoring return value of ‘setuid’, declared with attribute warn_unused_result [-Wunused-result]
       setuid(child_uid);
       ^~~~~~~~~~~~~~~~~
    
    Fixes: c67e8ec0 ("LSM: SafeSetID: add selftest")
    Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    295c4e21
safesetid-test.c 7.29 KB