diff options
author | Max Kellermann <max@duempel.org> | 2008-10-15 22:34:21 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-15 22:34:21 +0200 |
commit | 4a7ad5b618957f75da5b305a3d0cc8006e3e7416 (patch) | |
tree | 80947f009e0efe11e45b0e64ebb2b81cc5c16abe /src/client.c | |
parent | fa56ff3d5250219d39d3cb077fd1e265fd6f92be (diff) | |
download | mpd-4a7ad5b618957f75da5b305a3d0cc8006e3e7416.tar.gz mpd-4a7ad5b618957f75da5b305a3d0cc8006e3e7416.tar.xz mpd-4a7ad5b618957f75da5b305a3d0cc8006e3e7416.zip |
listen, client: enable SO_PASSCRED, get client's uid
Enable authentication over unix sockets. Store the client's uid in
the client struct.
Diffstat (limited to '')
-rw-r--r-- | src/client.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/client.c b/src/client.c index 5b3b161b5..f3e2b32a4 100644 --- a/src/client.c +++ b/src/client.c @@ -72,8 +72,13 @@ struct client { char buffer[CLIENT_MAX_BUFFER_LENGTH]; size_t bufferLength; size_t bufferPos; + int fd; /* file descriptor; -1 if expired */ int permission; + + /** the uid of the client process, or -1 if unknown */ + int uid; + time_t lastTime; struct strnode *cmd_list; /* for when in list mode */ struct strnode *cmd_list_tail; /* for when in list mode */ @@ -147,6 +152,11 @@ int client_is_expired(const struct client *client) return client->fd < 0; } +int client_get_uid(const struct client *client) +{ + return client->uid; +} + int client_get_permission(const struct client *client) { return client->permission; @@ -323,7 +333,7 @@ sockaddr_to_tmp_string(const struct sockaddr *addr) return hostname; } -void client_new(int fd, const struct sockaddr *addr) +void client_new(int fd, const struct sockaddr *addr, int uid) { struct client *client; @@ -337,6 +347,7 @@ void client_new(int fd, const struct sockaddr *addr) list_add(&client->siblings, &clients); ++num_clients; client_init(client, fd); + client->uid = uid; SECURE("client %i: opened from %s\n", client->num, sockaddr_to_tmp_string(addr)); } |