~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/python/_initgroups.c

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
  Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
 
4
  
 
5
  This software is subject to the provisions of the Zope Public License,
 
6
  Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
 
7
  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 
8
  WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
9
  WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 
10
  FOR A PARTICULAR PURPOSE
 
11
  
 
12
 ****************************************************************************/
 
13
 
 
14
/* 
 
15
 * This has been reported for inclusion in Python here: http://bugs.python.org/issue7333
 
16
 * Hopefully we may be able to remove this file in some years.
 
17
 */
 
18
 
 
19
#include "Python.h"
 
20
 
 
21
#if defined(__unix__) || defined(unix) || defined(__NetBSD__) || defined(__MACH__) /* Mac OS X */
 
22
 
 
23
#include <grp.h>
 
24
#include <sys/types.h>
 
25
#include <unistd.h>
 
26
 
 
27
static PyObject *
 
28
initgroups_initgroups(PyObject *self, PyObject *args)
 
29
{
 
30
        char *username;
 
31
        unsigned int igid;
 
32
        gid_t gid;
 
33
 
 
34
        if (!PyArg_ParseTuple(args, "sI:initgroups", &username, &igid))
 
35
                return NULL;
 
36
 
 
37
        gid = igid;
 
38
 
 
39
        if (initgroups(username, gid) == -1)
 
40
                return PyErr_SetFromErrno(PyExc_OSError);
 
41
 
 
42
        Py_INCREF(Py_None);
 
43
        return Py_None;
 
44
}
 
45
 
 
46
static PyMethodDef InitgroupsMethods[] = {
 
47
        {"initgroups",  initgroups_initgroups,  METH_VARARGS},
 
48
        {NULL,          NULL}
 
49
};
 
50
 
 
51
#else
 
52
 
 
53
/* This module is empty on non-UNIX systems. */
 
54
 
 
55
static PyMethodDef InitgroupsMethods[] = {
 
56
        {NULL,          NULL}
 
57
};
 
58
 
 
59
#endif /* defined(__unix__) || defined(unix) */
 
60
 
 
61
void
 
62
init_initgroups(void)
 
63
{
 
64
        Py_InitModule("_initgroups", InitgroupsMethods);
 
65
}
 
66