chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
importd: create a loopback btrfs file system for /var/lib/machines, if necessary
[elogind.git]
/
src
/
bus-proxyd
/
bus-proxyd.c
diff --git
a/src/bus-proxyd/bus-proxyd.c
b/src/bus-proxyd/bus-proxyd.c
index 478dd78744eb6d6639cbb49f2ebf2d30b44d438d..9645c504f538230906f5e145ed7d29f9aaeb9b8a 100644
(file)
--- a/
src/bus-proxyd/bus-proxyd.c
+++ b/
src/bus-proxyd/bus-proxyd.c
@@
-23,13
+23,9
@@
***/
#include <sys/socket.h>
***/
#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/types.h>
-#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
-#include <poll.h>
#include <sys/prctl.h>
#include <stddef.h>
#include <getopt.h>
#include <sys/prctl.h>
#include <stddef.h>
#include <getopt.h>
@@
-37,24
+33,14
@@
#include "log.h"
#include "util.h"
#include "log.h"
#include "util.h"
-#include "hashmap.h"
-#include "socket-util.h"
#include "sd-daemon.h"
#include "sd-daemon.h"
-#include "sd-bus.h"
#include "bus-internal.h"
#include "bus-internal.h"
-#include "bus-message.h"
-#include "bus-util.h"
#include "build.h"
#include "strv.h"
#include "def.h"
#include "capability.h"
#include "build.h"
#include "strv.h"
#include "def.h"
#include "capability.h"
-#include "bus-control.h"
-#include "smack-util.h"
-#include "set.h"
#include "bus-xml-policy.h"
#include "bus-xml-policy.h"
-#include "driver.h"
#include "proxy.h"
#include "proxy.h"
-#include "synthesize.h"
static char *arg_address = NULL;
static char **arg_configuration = NULL;
static char *arg_address = NULL;
static char **arg_configuration = NULL;
@@
-130,19
+116,18
@@
static int loop_clients(int accept_fd, uid_t bus_uid) {
r = pthread_attr_init(&attr);
if (r < 0) {
r = pthread_attr_init(&attr);
if (r < 0) {
- r = log_error_errno(errno, "Cannot initialize pthread attributes: %m");
- goto exit;
+ return log_error_errno(errno, "Cannot initialize pthread attributes: %m");
}
r = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (r < 0) {
r = log_error_errno(errno, "Cannot mark pthread attributes as detached: %m");
}
r = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (r < 0) {
r = log_error_errno(errno, "Cannot mark pthread attributes as detached: %m");
- goto
exit_attr
;
+ goto
finish
;
}
r = shared_policy_new(&sp);
if (r < 0)
}
r = shared_policy_new(&sp);
if (r < 0)
- goto
exit_attr
;
+ goto
finish
;
for (;;) {
ClientContext *c;
for (;;) {
ClientContext *c;
@@
-155,7
+140,7
@@
static int loop_clients(int accept_fd, uid_t bus_uid) {
continue;
r = log_error_errno(errno, "accept4() failed: %m");
continue;
r = log_error_errno(errno, "accept4() failed: %m");
-
break
;
+
goto finish
;
}
r = client_context_new(&c);
}
r = client_context_new(&c);
@@
-177,9
+162,8
@@
static int loop_clients(int accept_fd, uid_t bus_uid) {
}
}
}
}
-
exit_attr
:
+
finish
:
pthread_attr_destroy(&attr);
pthread_attr_destroy(&attr);
-exit:
return r;
}
return r;
}
@@
-234,17
+218,11
@@
static int parse_argv(int argc, char *argv[]) {
puts(SYSTEMD_FEATURES);
return 0;
puts(SYSTEMD_FEATURES);
return 0;
- case ARG_ADDRESS: {
- char *a;
-
- a = strdup(optarg);
- if (!a)
+ case ARG_ADDRESS:
+ r = free_and_strdup(&arg_address, optarg);
+ if (r < 0)
return log_oom();
return log_oom();
-
- free(arg_address);
- arg_address = a;
break;
break;
- }
case ARG_CONFIGURATION:
r = strv_extend(&arg_configuration, optarg);
case ARG_CONFIGURATION:
r = strv_extend(&arg_configuration, optarg);
@@
-296,7
+274,6
@@
static int parse_argv(int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
- const char *user = "systemd-bus-proxy";
int r, accept_fd;
uid_t uid, bus_uid;
gid_t gid;
int r, accept_fd;
uid_t uid, bus_uid;
gid_t gid;
@@
-308,6
+285,8
@@
int main(int argc, char *argv[]) {
bus_uid = getuid();
if (geteuid() == 0) {
bus_uid = getuid();
if (geteuid() == 0) {
+ const char *user = "systemd-bus-proxy";
+
r = get_user_creds(&user, &uid, &gid, NULL, NULL);
if (r < 0) {
log_error_errno(r, "Cannot resolve user name %s: %m", user);
r = get_user_creds(&user, &uid, &gid, NULL, NULL);
if (r < 0) {
log_error_errno(r, "Cannot resolve user name %s: %m", user);
@@
-332,6
+311,7
@@
int main(int argc, char *argv[]) {
}
accept_fd = SD_LISTEN_FDS_START;
}
accept_fd = SD_LISTEN_FDS_START;
+
r = fd_nonblock(accept_fd, false);
if (r < 0) {
log_error_errno(r, "Cannot mark accept-fd non-blocking: %m");
r = fd_nonblock(accept_fd, false);
if (r < 0) {
log_error_errno(r, "Cannot mark accept-fd non-blocking: %m");