@@ -3112,7 +3112,7 @@ main (int argc,
31123112 }
31133113
31143114 /* Switch to the custom user ns before the clone, gets us privs in that ns (assuming its a child of the current and thus allowed) */
3115- if (opt_userns_fd > 0 && setns (opt_userns_fd , CLONE_NEWUSER ) != 0 )
3115+ if (opt_userns_fd != -1 && setns (opt_userns_fd , CLONE_NEWUSER ) != 0 )
31163116 {
31173117 if (errno == EINVAL )
31183118 die ("Joining the specified user namespace failed, it might not be a descendant of the current user namespace." );
@@ -3178,7 +3178,7 @@ main (int argc,
31783178
31793179 /* Initial launched process, wait for pid 1 or exec:ed command to exit */
31803180
3181- if (opt_userns2_fd > 0 && setns (opt_userns2_fd , CLONE_NEWUSER ) != 0 )
3181+ if (opt_userns2_fd != -1 && setns (opt_userns2_fd , CLONE_NEWUSER ) != 0 )
31823182 die_with_error ("Setting userns2 failed" );
31833183
31843184 /* We don't need any privileges in the launcher, drop them immediately. */
@@ -3219,7 +3219,7 @@ main (int argc,
32193219 return monitor_child (event_fd , pid , setup_finished_pipe [0 ]);
32203220 }
32213221
3222- if (opt_pidns_fd > 0 )
3222+ if (opt_pidns_fd != -1 )
32233223 {
32243224 if (setns (opt_pidns_fd , CLONE_NEWPID ) != 0 )
32253225 die_with_error ("Setting pidns failed" );
@@ -3446,7 +3446,7 @@ main (int argc,
34463446 die_with_error ("chdir /" );
34473447 }
34483448
3449- if (opt_userns2_fd > 0 && setns (opt_userns2_fd , CLONE_NEWUSER ) != 0 )
3449+ if (opt_userns2_fd != -1 && setns (opt_userns2_fd , CLONE_NEWUSER ) != 0 )
34503450 die_with_error ("Setting userns2 failed" );
34513451
34523452 if (opt_unshare_user && opt_userns_block_fd == -1 &&
0 commit comments