Move the setuid call after mlockall, since the latter requires elevated
privileges, and will cause iscsid startup to fail when an unprivileged
uid is specified.

Signed-off-by: Anthony Iliopoulos <[email protected]>
---
 usr/iscsid.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/usr/iscsid.c b/usr/iscsid.c
index e50149823bee..9f1a09fe28f2 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -525,12 +525,6 @@ int main(int argc, char *argv[])
                }
        }
 
-       if (uid && setuid(uid) < 0) {
-               log_error("Unable to setuid to %d", uid);
-               log_close(log_pid);
-               exit(ISCSI_ERR);
-       }
-
        memset(&daemon_config, 0, sizeof (daemon_config));
        daemon_config.pid_file = pid_file;
        daemon_config.config_file = config_file;
@@ -601,6 +595,12 @@ int main(int argc, char *argv[])
                exit(ISCSI_ERR);
        }
 
+       if (uid && setuid(uid) < 0) {
+               log_error("Unable to setuid to %d", uid);
+               log_close(log_pid);
+               exit(ISCSI_ERR);
+       }
+
        set_state_to_ready();
        event_loop(ipc, control_fd, mgmt_ipc_fd);
 
-- 
2.29.0

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/20201020105722.8938-1-ailiop%40suse.com.

Reply via email to