~ubuntu-branches/ubuntu/quantal/lxc/quantal-201208301614

« back to all changes in this revision

Viewing changes to src/lxc/af_unix.c

  • Committer: Bazaar Package Importer
  • Author(s): Guido Trotter, Stéphane Graber, Guido Trotter
  • Date: 2010-01-10 10:40:21 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20100110104021-25cm8w09ccmw5w2z
[ Stéphane Graber ]
* Upgrade standards-version to 3.8.3
* Drop the copy of etc/* from rules as "etc" is no longer in the tarball

[ Guido Trotter ]
* New Upstream Version
* Update libcap2-dev dependency to libcap-dev
* Install upstream-built man pages via debian/lxc.manpages
* Drop unneeded docbook-utils build dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <string.h>
24
24
#include <unistd.h>
25
25
#include <fcntl.h>
 
26
#include <errno.h>
26
27
#define __USE_GNU
27
28
#include <sys/socket.h>
28
29
#undef __USE_GNU
29
30
#include <sys/un.h>
30
31
 
 
32
#include "log.h"
 
33
 
 
34
lxc_log_define(lxc_af_unix, lxc);
31
35
 
32
36
int lxc_af_unix_open(const char *path, int type, int flags)
33
37
{
229
233
 
230
234
        cmsg = CMSG_FIRSTHDR(&msg);
231
235
 
232
 
        ret = -1;
233
 
 
234
236
        if (cmsg && cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred)) &&
235
237
            cmsg->cmsg_level == SOL_SOCKET &&
236
238
            cmsg->cmsg_type == SCM_CREDENTIALS) {
237
239
                cred = *((struct ucred *) CMSG_DATA(cmsg));
238
 
                if (cred.uid == getuid() && cred.gid == getgid())
239
 
                        ret = 0;
 
240
                if (cred.uid && (cred.uid != getuid() || cred.gid != getgid())) {
 
241
                        INFO("message denied for '%d/%d'", cred.uid, cred.gid);
 
242
                        return -EACCES;
 
243
                }
240
244
        }
241
245
out:
242
246
        return ret;