Blame SOURCES/libssh-0.8.91-run-sshd-confined.patch

4f479a
diff --git a/tests/torture.c b/tests/torture.c
4f479a
index 772942c2..8e420b35 100644
4f479a
--- a/tests/torture.c
4f479a
+++ b/tests/torture.c
4f479a
@@ -854,7 +854,7 @@ void torture_setup_sshd_server(void **state, bool pam)
4f479a
     s = *state;
4f479a
 
4f479a
     snprintf(sshd_start_cmd, sizeof(sshd_start_cmd),
4f479a
-             "/usr/sbin/sshd -r -f %s -E %s/sshd/daemon.log 2> %s/sshd/cwrap.log",
4f479a
+             "runcon -t sshd_t -u system_u -r system_r /usr/sbin/sshd -r -f %s -E %s/sshd/daemon.log 2> %s/sshd/cwrap.log",
4f479a
              s->srv_config, s->socket_dir, s->socket_dir);
4f479a
 
4f479a
     rc = system(sshd_start_cmd);
4f479a
@@ -864,7 +864,7 @@ void torture_setup_sshd_server(void **state, bool pam)
4f479a
     unsetenv("PAM_WRAPPER");
4f479a
 
4f479a
     /* Wait until the sshd is ready to accept connections */
4f479a
-    rc = torture_wait_for_daemon(5);
4f479a
+    rc = torture_wait_for_daemon(10);
4f479a
     assert_int_equal(rc, 0);
4f479a
 }
4f479a
 
4f479a
@@ -905,26 +905,32 @@ torture_reload_sshd_server(void **state)
4f479a
 {
4f479a
     struct torture_state *s = *state;
4f479a
     pid_t pid;
4f479a
+    char sshd_start_cmd[1024];
4f479a
     int rc;
4f479a
 
4f479a
-    /* read the pidfile */
4f479a
-    pid = torture_read_pidfile(s->srv_pidfile);
4f479a
-    assert_int_not_equal(pid, -1);
4f479a
+    rc = torture_terminate_process(s->srv_pidfile);
4f479a
+    if (rc != 0) {
4f479a
+        fprintf(stderr, "XXXXXX Failed to terminate sshd\n");
4f479a
+    }
4f479a
 
4f479a
-    kill(pid, SIGHUP);
4f479a
+    usleep(100 * 1000);
4f479a
 
4f479a
-    /* 10 ms */
4f479a
-    usleep(10 * 1000);
4f479a
+    /* Set the default interface for the server */
4f479a
+    setenv("SOCKET_WRAPPER_DEFAULT_IFACE", "10", 1);
4f479a
+    setenv("PAM_WRAPPER", "1", 1);
4f479a
 
4f479a
-    rc = kill(pid, 0);
4f479a
-    if (rc != 0) {
4f479a
-        fprintf(stderr,
4f479a
-                "ERROR: SSHD process %u died during reload!\n", pid);
4f479a
-        return SSH_ERROR;
4f479a
-    }
4f479a
+    snprintf(sshd_start_cmd, sizeof(sshd_start_cmd),
4f479a
+             "runcon -t sshd_t -u system_u -r system_r /usr/sbin/sshd -r -f %s -E %s/sshd/daemon.log 2> %s/sshd/cwrap.log",
4f479a
+             s->srv_config, s->socket_dir, s->socket_dir);
4f479a
+
4f479a
+    rc = system(sshd_start_cmd);
4f479a
+    assert_return_code(rc, errno);
4f479a
+
4f479a
+    setenv("SOCKET_WRAPPER_DEFAULT_IFACE", "21", 1);
4f479a
+    unsetenv("PAM_WRAPPER");
4f479a
 
4f479a
     /* Wait until the sshd is ready to accept connections */
4f479a
-    rc = torture_wait_for_daemon(5);
4f479a
+    rc = torture_wait_for_daemon(10);
4f479a
     assert_int_equal(rc, 0);
4f479a
     return SSH_OK;
4f479a
 }