2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
5 * Ucred.xs contains XS wrappers for the process privilege maniplulation
10 /* Solaris includes. */
20 typedef priv_set_t Sun__Solaris__Privilege__Privset;
21 typedef ucred_t Sun__Solaris__Ucred__Ucred;
24 dupset(const priv_set_t *s)
26 priv_set_t *new = priv_allocset();
34 #define RETPRIVSET(set) \
35 ST(0) = sv_newmortal(); \
36 sv_setref_pv(ST(0), "Sun::Solaris::Privilege::PrivsetPtr", \
38 SvREADONLY_on(SvRV(ST(0)))
40 #define RETUCRED(uc) \
41 ST(0) = sv_newmortal(); \
42 sv_setref_pv(ST(0), "Sun::Solaris::Ucred::UcredPtr", \
44 SvREADONLY_on(SvRV(ST(0)))
46 * The XS code exported to perl is below here. Note that the XS preprocessor
47 * has its own commenting syntax, so all comments from this point on are in
51 MODULE = Sun::Solaris::Ucred PACKAGE = Sun::Solaris::Ucred
54 Sun::Solaris::Ucred::Ucred *
60 Sun::Solaris::Ucred::Ucred *uc;
64 Sun::Solaris::Ucred::Ucred *uc;
68 Sun::Solaris::Ucred::Ucred *uc;
72 Sun::Solaris::Ucred::Ucred *uc;
76 Sun::Solaris::Ucred::Ucred *uc;
80 Sun::Solaris::Ucred::Ucred *uc;
84 Sun::Solaris::Ucred::Ucred *uc;
88 Sun::Solaris::Ucred::Ucred *uc;
92 Sun::Solaris::Ucred::Ucred *uc;
95 ucred_getpflags(uc, flags)
96 Sun::Solaris::Ucred::Ucred *uc;
99 Sun::Solaris::Privilege::Privset *
100 ucred_getprivset(uc, which)
101 Sun::Solaris::Ucred::Ucred *uc;
104 const priv_set_t *val;
107 * Since this function returns a pointer into the ucred_t, we need
108 * to copy it or perl may free one before the other; and the
109 * priv_set_t * returned by it doesn't react kindly to free().
111 val = ucred_getprivset(uc, which);
112 if (val == NULL || (RETVAL = dupset(val)) == NULL)
116 Sun::Solaris::Ucred::Ucred *
121 if (getpeerucred(fd, &RETVAL) != 0)
127 Sun::Solaris::Ucred::Ucred *uc;
132 n = ucred_getgroups(uc, &gids);
137 if (GIMME_V == G_SCALAR) {
139 PUSHs(sv_2mortal(newSViv(n)));
142 } else if (GIMME_V == G_ARRAY) {
146 for (i = 0; i < n; i++)
147 PUSHs(sv_2mortal(newSViv(gids[i])));
158 MODULE = Sun::Solaris::Ucred PACKAGE = Sun::Solaris::Ucred::UcredPtr PREFIX = Ucred_
162 Sun::Solaris::Ucred::Ucred *uc;