return 0;
}
-int openpt_allocate_in_namespace(pid_t pid, int flags, char **ret_peer_path) {
+int openpt_allocate_in_namespace(
+ const PidRef *pidref,
+ int flags,
+ char **ret_peer_path) {
+
_cleanup_close_ int pidnsfd = -EBADF, mntnsfd = -EBADF, usernsfd = -EBADF, rootfd = -EBADF, fd = -EBADF;
_cleanup_close_pair_ int pair[2] = EBADF_PAIR;
int r;
- assert(pid > 0);
-
- r = namespace_open(pid, &pidnsfd, &mntnsfd, /* ret_netns_fd = */ NULL, &usernsfd, &rootfd);
+ r = pidref_namespace_open(pidref, &pidnsfd, &mntnsfd, /* ret_netns_fd = */ NULL, &usernsfd, &rootfd);
if (r < 0)
return r;
return TAKE_FD(fd);
}
-int open_terminal_in_namespace(pid_t pid, const char *name, int mode) {
+int open_terminal_in_namespace(
+ const PidRef *pidref,
+ const char *name,
+ int mode) {
+
_cleanup_close_ int pidnsfd = -EBADF, mntnsfd = -EBADF, usernsfd = -EBADF, rootfd = -EBADF;
_cleanup_close_pair_ int pair[2] = EBADF_PAIR;
int r;
- assert(pid > 0);
assert(name);
- r = namespace_open(pid, &pidnsfd, &mntnsfd, /* ret_netns_fd= */ NULL, &usernsfd, &rootfd);
+ r = pidref_namespace_open(pidref, &pidnsfd, &mntnsfd, /* ret_netns_fd= */ NULL, &usernsfd, &rootfd);
if (r < 0)
return r;
#include <unistd.h>
#include "macro.h"
+#include "pidref.h"
#include "time-util.h"
/* Erase characters until the end of the line */
int ptsname_malloc(int fd, char **ret);
int openpt_allocate(int flags, char **ret_peer);
-int openpt_allocate_in_namespace(pid_t pid, int flags, char **ret_peer);
-int open_terminal_in_namespace(pid_t pid, const char *name, int mode);
+int openpt_allocate_in_namespace(const PidRef *pidref, int flags, char **ret_peer);
+int open_terminal_in_namespace(const PidRef *pidref, const char *name, int mode);
int vt_restore(int fd);
int vt_release(int fd, bool restore_vt);
if (!pidref_is_set(&m->leader))
return -EINVAL;
- return openpt_allocate_in_namespace(m->leader.pid, flags, ret_peer);
+ return openpt_allocate_in_namespace(&m->leader, flags, ret_peer);
default:
return -EOPNOTSUPP;
if (!pidref_is_set(&m->leader))
return -EINVAL;
- return open_terminal_in_namespace(m->leader.pid, path, mode);
+ return open_terminal_in_namespace(&m->leader, path, mode);
default:
return -EOPNOTSUPP;