1998-10-18 15:16:22 +00:00
|
|
|
/* Cache handling for group lookup.
|
2000-04-28 05:12:30 +00:00
|
|
|
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
1998-01-31 08:39:55 +00:00
|
|
|
This file is part of the GNU C Library.
|
1998-10-18 15:16:22 +00:00
|
|
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
1998-01-31 08:39:55 +00:00
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
|
|
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
1998-10-18 15:16:22 +00:00
|
|
|
Boston, MA 02111-1307, USA. */
|
1998-01-31 08:39:55 +00:00
|
|
|
|
|
|
|
#include <errno.h>
|
1998-10-18 15:16:22 +00:00
|
|
|
#include <error.h>
|
1998-01-31 08:39:55 +00:00
|
|
|
#include <grp.h>
|
1998-10-18 15:16:22 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
2000-09-29 16:45:44 +00:00
|
|
|
#include <stdint.h>
|
Update.
1998-02-10 23:57 Ulrich Drepper <drepper@happy.cygnus.com>
* misc/tst-efgcvt.c: Add more tests.
* misc/efgcvt_r.c: Correct result for above new tests.
1998-02-06 17:22 H.J. Lu <hjl@gnu.org>
* misc/efgcvt_r.c (fcvt_r, ecvt_r): Correctly handle
NDIGIT <= 0.
1998-02-10 16:48 Philip Blundell <pb@nexus.co.uk>
* Makerules (install-no-libc.a-nosubdir): Don't install-bin (etc)
if the programs weren't built.
1998-02-09 10:12 Philip Blundell <pb@nexus.co.uk>
* sysdeps/libm-ieee754/s_exp2.c (__ieee754_exp2): If we don't have
FE_TONEAREST, soldier on regardless and do the best we can.
* sysdeps/libm-ieee754/s_exp2f.c (__ieee754_exp2f): likewise.
1998-02-5 17:20 Philip Blundell <pb@nexus.co.uk>
* sysdeps/standalone/filedesc.h: Define __need_FOPEN_MAX, not
_STDIO_H, before including <bits/stdio_lim.h>.
* sysdeps/standalone/arm/bits/errno.h (EOVERFLOW): Added.
* io/fts.c (fts_build): Don't try to use d_type if it doesn't
exist.
* sysdeps/arm/sys/ucontext.h: New file.
1998-02-04 10:11 Philip Blundell <pb@nexus.co.uk>
* manual/stdio.texi (Formatted Output Functions): Explicitly say
that the return value from snprintf() does not count the
terminating NUL as a character.
1998-02-10 16:57 Ulrich Drepper <drepper@happy.cygnus.com>
* manual/users.texi: Rewrite to describe correct POSIX behaviour,
add description for sete[ug]id and general cleanup.
Patch by Zack Weinberg <zack@rabi.phys.columbia.edu>.
1998-01-04 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* Makefile (parent-clean): Don't remove makefile fragments here.
(postclean): New variable.
(clean): Remove makefile fragments here.
(realclean distclean): Likewise. Pass sysdep-subdirs to sub-make.
(generated): Add isomac and isomanc.out.
* Makeconfig ($(common-objpfx)soversions.mk): Don't generate if
avoid-generated is set.
(postclean-generated): Add soversion.mk.
($(common-objpfx)version.mk): Don't include if avoid-generated is
set.
* Makerules: Still need to include $(+sysdir_pfx)sysd-Makefile if
avoid-generated is set.
(common-generated): Add libc.so and libc.so$(libc.so-version).
(generated): Add versioned libraries.
(common-mostlyclean): Also remove %.so and %_pic.a.
* csu/Makefile (generated): Add abi-tag.h.
* db2/Makefile (extra-objs): Add getlong.o.
* elf/Makefile (generated): Add ld.so, ldd and
$(rtld-installed-name).
(others): Add ldconfig here instead of ldconfig.o to extra-objs.
* malloc/Makefile (generated): Add mtrace.
* po/Makefile: Don't include version.mk, not needed any more.
* sunrpc/Makefile (generated): Add rpc-proto.d and rpcgen.
* sysdeps/unix/Makefile: Fix local_lim.h -> bits/local_lim.h,
syscall.h -> sys/syscall.h.
(common-generated): Add s-proto.d.
(postclean-generated): Add sysd-syscalls.
* localedata/Makefile (test-output): Add all output files.
(generated): Add test-input and test-output.
(generated-dirs): Add all the dirs.
1998-01-04 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* Makefile (test-output, generated, generated-dirs): New
variables.
1998-02-10 16:57 Ulrich Drepper <drepper@happy.cygnus.com>
* resolv/nss_dns/dns-host.c: Various code cleanups.
1998-02-09 08:10 H.J. Lu <hjl@gnu.org>
* resolv/gethnamaddr.c (getanswer): Fix the PTR/CNAME bug.
From Philip Blundell <pb@nexus.co.uk>.
* resolv/nss_dns/dns-host.c (getanswer_r): Ditto.
1998-02-08 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* libc.map: Add .rem, .div, .mul, .udiv, .umul, .urem for Sparc.
Suggested by debian/sparc porters.
1998-02-07 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* misc/tst-efgcvt.c: Totally rewritten, added a lot of new tests
for ecvt and fcvt.
1998-02-10 16:32 Ulrich Drepper <drepper@happy.cygnus.com>
* sysdeps/unix/sysv/linux/ptsname.c (__ptsname_r): Use __xstat and
__fxstat instead of stat and fstat. Use namespace clean __stpcpy.
* signal/signal.h: Always define sigset_t if __need_sigset_t is
defined even if __USE_POSIX is not defined.
1998-02-02 20:51 Zack Weinberg <zack@rabi.phys.columbia.edu>
* sysdeps/unix/sysv/linux/ptsname.c (__ptsname_r): Correct last patch
to support obsolete tty major numbers correctly.
1998-02-02 08:47 H.J. Lu <hjl@gnu.org>
* login/Makefile ($(inst_libexecdir)/pt_chown): Make the target
directory first and ignore install error.
* sysdeps/unix/sysv/linux/ptsname.c (__ptsname_r): Substract
128 from ptyno and fix a typo for the BSD style pty.
1998-02-01 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/unix/Makefile ($(common-objpfx)s-proto.d): Depend on all
syscalls.list's.
1998-02-01 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add
getresuid and getresgid.
* sysdeps/unix/sysv/linux/getresuid.c: New file.
* sysdeps/unix/sysv/linux/getresgid.c: New file.
* sysdeps/unix/sysv/linux/syscalls.list: Remove getres[ug]id, add
s_getres[ug]id.
* sysdeps/unix/sysv/linux/alpha/syscalls.list: Add getres[ug]id.
* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/powerpc/syscalls.list: Likewise.
1998-02-02 08:11 H.J. Lu <hjl@gnu.org>
* nscd/grpcache.c: Include <stdlib.h>.
1998-02-01 16:01 H.J. Lu <hjl@gnu.org>
* stdlib/atoll.c: Fix comments.
* sysdeps/posix/ttyname.c: Ignore stdin/stdout/stderr.
* sysdeps/posix/ttyname_r.c: Ditto.
1998-02-03 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* io/sys/stat.h: Define S_IFLNK and S_IFSOCK if __USE_BSD or
__USE_MISC, independent of __USE_UNIX98.
1998-02-10 19:18 Ulrich Drepper <drepper@happy.cygnus.com>
* sysdeps/unix/sysv/linux/i386/sigaction.c (__libc_missing_rt_sigs):
Rename from __libc_have_rt_sigs and leave as COMMON data.
1998-02-04 11:58 Richard Henderson <rth@twiddle.rth.home>
* Makeconfig (CFLAGS-.os): Kill -fno-common.
* Makerules (libc.so): Prelink libc_pic.a, allocating commons.
* libc.map (GLIBC_2.1): Add Linux/Alpha tv64 symbols.
* elf/rtld.map: New file. Needed to define the GLIBC_2.*
version symbols.
* include/libc-symbols.h (symbol_version, default_symbol_version):
Provide asm versions and correct !DO_VERSIONING versions.
* sysdeps/unix/make-syscalls.sh: Recognize version symbols in
the weak symbol list.
* sysdeps/unix/sysv/linux/sigaction.c (__libc_missing_rt_sigs):
Rename from __libc_have_rt_sigs and leave as COMMON data.
* sysdeps/unix/sysv/linux/sigpending.c: Likewise.
* sysdeps/unix/sysv/linux/sigprocmask.c: Likewise.
* sysdeps/unix/sysv/linux/sigsuspend.c: Likewise.
1998-02-04 16:41 Zack Weinberg <zack@rabi.phys.columbia.edu>
* sunrpc/Makefile: Correct dependencies of rpcgen.
1998-02-10 03:00 Ulrich Drepper <drepper@happy.cygnus.com>
* nscd/Makefile: Fix test for available linuxthreads add-on.
Patch by Zack Weinberg <zack@rabi.phys.columbia.edu>.
1998-02-05 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sysdeps/unix/sysv/linux/syscalls.list: Fix typo in lchown.
1998-02-03 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sysdeps/gnu/Makefile: Respect with-cvs variable.
* manual/errno.texi (Error Messages): Correct description of
strerror_r. Pointed out by jonas@bagge.se.
1998-01-29 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* manual/socket.texi (Host Address Functions): Clarify description
of inet_network.
1998-02-07 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/unix/grantpt.c (argv): Move const to toplevel.
(grantpt): Delete superfluous cast.
1998-02-06 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* Makefile ($(inst_slibdir)/libc-$(version).so): Depend on
elf/ldso_install instead of elf/subdir_install.
(elf/ldso_install): New target.
* elf/Makefile (ldso_install): New target.
1998-02-07 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/unix/sysv/linux/powerpc/socket.S: Really do the change
of 1998-01-06.
1998-02-07 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* string/bits/string2.h (strcmp): Use __string2_1bptr_p only for
constant expressions.
1998-02-07 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* nss/test-netdb.c: Include <unistd.h> for gethostname and "nss.h"
for __nss_configure_lookup.
(output_hostent): Remove unused variable.
1998-02-07 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* string/tst-inlcall.c: Fix format string.
1998-02-09 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* inet/netinet/in.h: Rename second parameter of bindresvport to
avoid buggy gcc warning. [PR libc/412]
1998-02-10 20:06:30 +00:00
|
|
|
#include <stdlib.h>
|
1998-01-31 08:39:55 +00:00
|
|
|
#include <string.h>
|
1998-07-04 10:39:13 +00:00
|
|
|
#include <unistd.h>
|
1999-06-19 09:58:37 +00:00
|
|
|
#include <libintl.h>
|
1998-01-31 08:39:55 +00:00
|
|
|
|
|
|
|
#include "nscd.h"
|
1998-10-18 15:16:22 +00:00
|
|
|
#include "dbg_log.h"
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* This is the standard reply in case the service is disabled. */
|
|
|
|
static const gr_response_header disabled =
|
1998-01-31 08:39:55 +00:00
|
|
|
{
|
1998-10-18 15:16:22 +00:00
|
|
|
version: NSCD_VERSION,
|
|
|
|
found: -1,
|
|
|
|
gr_name_len: 0,
|
|
|
|
gr_passwd_len: 0,
|
|
|
|
gr_gid: -1,
|
|
|
|
gr_mem_cnt: 0,
|
1998-01-31 08:39:55 +00:00
|
|
|
};
|
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* This is the struct describing how to write this record. */
|
|
|
|
const struct iovec grp_iov_disabled =
|
1998-01-31 08:39:55 +00:00
|
|
|
{
|
1998-10-18 15:16:22 +00:00
|
|
|
iov_base: (void *) &disabled,
|
|
|
|
iov_len: sizeof (disabled)
|
1998-01-31 08:39:55 +00:00
|
|
|
};
|
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
|
|
|
|
/* This is the standard reply in case we haven't found the dataset. */
|
|
|
|
static const gr_response_header notfound =
|
1998-01-31 08:39:55 +00:00
|
|
|
{
|
1998-10-18 15:16:22 +00:00
|
|
|
version: NSCD_VERSION,
|
|
|
|
found: 0,
|
|
|
|
gr_name_len: 0,
|
|
|
|
gr_passwd_len: 0,
|
|
|
|
gr_gid: -1,
|
|
|
|
gr_mem_cnt: 0,
|
1998-01-31 08:39:55 +00:00
|
|
|
};
|
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* This is the struct describing how to write this record. */
|
|
|
|
static const struct iovec iov_notfound =
|
1998-01-31 08:39:55 +00:00
|
|
|
{
|
1998-10-18 15:16:22 +00:00
|
|
|
iov_base: (void *) ¬found,
|
|
|
|
iov_len: sizeof (notfound)
|
|
|
|
};
|
1998-01-31 08:39:55 +00:00
|
|
|
|
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
struct groupdata
|
1998-01-31 08:39:55 +00:00
|
|
|
{
|
1998-10-18 15:16:22 +00:00
|
|
|
gr_response_header resp;
|
|
|
|
char strdata[0];
|
|
|
|
};
|
1998-01-31 08:39:55 +00:00
|
|
|
|
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
static void
|
|
|
|
cache_addgr (struct database *db, int fd, request_header *req, void *key,
|
1999-06-11 20:58:21 +00:00
|
|
|
struct group *grp, uid_t owner)
|
1998-01-31 08:39:55 +00:00
|
|
|
{
|
1998-10-18 15:16:22 +00:00
|
|
|
ssize_t total;
|
|
|
|
ssize_t written;
|
|
|
|
time_t t = time (NULL);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
if (grp == NULL)
|
1998-01-31 08:39:55 +00:00
|
|
|
{
|
1998-10-18 15:16:22 +00:00
|
|
|
/* We have no data. This means we send the standard reply for this
|
|
|
|
case. */
|
|
|
|
void *copy;
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
total = sizeof (notfound);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
written = writev (fd, &iov_notfound, 1);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
copy = malloc (req->key_len);
|
|
|
|
if (copy == NULL)
|
|
|
|
error (EXIT_FAILURE, errno, _("while allocating key copy"));
|
|
|
|
memcpy (copy, key, req->key_len);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* Compute the timeout time. */
|
|
|
|
t += db->negtimeout;
|
1998-02-24 15:22:29 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* Now get the lock to safely insert the records. */
|
|
|
|
pthread_rwlock_rdlock (&db->lock);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1999-06-24 13:08:20 +00:00
|
|
|
cache_add (req->type, copy, req->key_len, ¬found,
|
1999-06-11 20:58:21 +00:00
|
|
|
sizeof (notfound), (void *) -1, 0, t, db, owner);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
pthread_rwlock_unlock (&db->lock);
|
1998-01-31 08:39:55 +00:00
|
|
|
}
|
1998-07-04 10:39:13 +00:00
|
|
|
else
|
|
|
|
{
|
1998-10-18 15:16:22 +00:00
|
|
|
/* Determine the I/O structure. */
|
|
|
|
struct groupdata *data;
|
|
|
|
size_t gr_name_len = strlen (grp->gr_name) + 1;
|
|
|
|
size_t gr_passwd_len = strlen (grp->gr_passwd) + 1;
|
|
|
|
size_t gr_mem_cnt = 0;
|
2000-09-29 16:45:44 +00:00
|
|
|
uint32_t *gr_mem_len;
|
1998-10-18 15:16:22 +00:00
|
|
|
size_t gr_mem_len_total = 0;
|
|
|
|
char *gr_name;
|
|
|
|
char *cp;
|
|
|
|
char buf[12];
|
|
|
|
ssize_t n;
|
|
|
|
size_t cnt;
|
|
|
|
|
|
|
|
/* We need this to insert the `bygid' entry. */
|
|
|
|
n = snprintf (buf, sizeof (buf), "%d", grp->gr_gid) + 1;
|
|
|
|
|
|
|
|
/* Determine the length of all members. */
|
|
|
|
while (grp->gr_mem[gr_mem_cnt])
|
|
|
|
++gr_mem_cnt;
|
2000-09-29 16:45:44 +00:00
|
|
|
gr_mem_len = (uint32_t *) alloca (gr_mem_cnt * sizeof (uint32_t));
|
1998-10-18 15:16:22 +00:00
|
|
|
for (gr_mem_cnt = 0; grp->gr_mem[gr_mem_cnt]; ++gr_mem_cnt)
|
|
|
|
{
|
|
|
|
gr_mem_len[gr_mem_cnt] = strlen (grp->gr_mem[gr_mem_cnt]) + 1;
|
|
|
|
gr_mem_len_total += gr_mem_len[gr_mem_cnt];
|
|
|
|
}
|
1998-07-04 10:39:13 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* We allocate all data in one memory block: the iov vector,
|
|
|
|
the response header and the dataset itself. */
|
|
|
|
total = (sizeof (struct groupdata)
|
2000-09-29 16:45:44 +00:00
|
|
|
+ gr_mem_cnt * sizeof (uint32_t)
|
1998-10-18 15:16:22 +00:00
|
|
|
+ gr_name_len + gr_passwd_len + gr_mem_len_total);
|
|
|
|
data = (struct groupdata *) malloc (total + n);
|
|
|
|
if (data == NULL)
|
|
|
|
/* There is no reason to go on. */
|
|
|
|
error (EXIT_FAILURE, errno, _("while allocating cache entry"));
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
data->resp.found = 1;
|
|
|
|
data->resp.gr_name_len = gr_name_len;
|
|
|
|
data->resp.gr_passwd_len = gr_passwd_len;
|
|
|
|
data->resp.gr_gid = grp->gr_gid;
|
|
|
|
data->resp.gr_mem_cnt = gr_mem_cnt;
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
cp = data->strdata;
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* This is the member string length array. */
|
2000-09-29 16:45:44 +00:00
|
|
|
cp = mempcpy (cp, gr_mem_len, gr_mem_cnt * sizeof (uint32_t));
|
2000-04-28 05:12:30 +00:00
|
|
|
gr_name = cp;
|
|
|
|
cp = mempcpy (cp, grp->gr_name, gr_name_len);
|
1998-10-18 15:16:22 +00:00
|
|
|
cp = mempcpy (cp, grp->gr_passwd, gr_passwd_len);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
for (cnt = 0; cnt < gr_mem_cnt; ++cnt)
|
|
|
|
cp = mempcpy (cp, grp->gr_mem[cnt], gr_mem_len[cnt]);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* Finally the stringified GID value. */
|
|
|
|
memcpy (cp, buf, n);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* Write the result. */
|
|
|
|
written = write (fd, &data->resp, total);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* Compute the timeout time. */
|
|
|
|
t += db->postimeout;
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* Now get the lock to safely insert the records. */
|
|
|
|
pthread_rwlock_rdlock (&db->lock);
|
1998-02-24 15:22:29 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
/* We have to add the value for both, byname and byuid. */
|
|
|
|
cache_add (GETGRBYNAME, gr_name, gr_name_len, data,
|
1999-06-11 20:58:21 +00:00
|
|
|
total, data, 0, t, db, owner);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1999-06-11 20:58:21 +00:00
|
|
|
cache_add (GETGRBYGID, cp, n, data, total, data, 1, t, db, owner);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
pthread_rwlock_unlock (&db->lock);
|
1998-01-31 08:39:55 +00:00
|
|
|
}
|
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
if (written != total)
|
1998-01-31 08:39:55 +00:00
|
|
|
{
|
1998-10-18 15:16:22 +00:00
|
|
|
char buf[256];
|
|
|
|
dbg_log (_("short write in %s: %s"), __FUNCTION__,
|
|
|
|
strerror_r (errno, buf, sizeof (buf)));
|
1998-01-31 08:39:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
void
|
1999-06-11 20:58:21 +00:00
|
|
|
addgrbyname (struct database *db, int fd, request_header *req,
|
|
|
|
void *key, uid_t uid)
|
1998-10-18 15:16:22 +00:00
|
|
|
{
|
|
|
|
/* Search for the entry matching the key. Please note that we don't
|
|
|
|
look again in the table whether the dataset is now available. We
|
|
|
|
simply insert it. It does not matter if it is in there twice. The
|
|
|
|
pruning function only will look at the timestamp. */
|
|
|
|
int buflen = 256;
|
|
|
|
char *buffer = alloca (buflen);
|
|
|
|
struct group resultbuf;
|
|
|
|
struct group *grp;
|
1999-06-11 20:58:21 +00:00
|
|
|
uid_t oldeuid = 0;
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
if (debug_level > 0)
|
|
|
|
dbg_log (_("Haven't found \"%s\" in group cache!"), key);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1999-06-11 20:58:21 +00:00
|
|
|
if (secure[grpdb])
|
|
|
|
{
|
|
|
|
oldeuid = geteuid ();
|
|
|
|
seteuid (uid);
|
|
|
|
}
|
|
|
|
|
1999-07-12 18:11:40 +00:00
|
|
|
while (__getgrnam_r (key, &resultbuf, buffer, buflen, &grp) != 0
|
1998-10-18 15:16:22 +00:00
|
|
|
&& errno == ERANGE)
|
1998-01-31 08:39:55 +00:00
|
|
|
{
|
1998-10-18 15:16:22 +00:00
|
|
|
errno = 0;
|
|
|
|
buflen += 256;
|
|
|
|
buffer = alloca (buflen);
|
1998-01-31 08:39:55 +00:00
|
|
|
}
|
|
|
|
|
1999-06-11 20:58:21 +00:00
|
|
|
if (secure[grpdb])
|
|
|
|
seteuid (oldeuid);
|
|
|
|
|
|
|
|
cache_addgr (db, fd, req, key, grp, uid);
|
1998-01-31 08:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
void
|
1999-06-11 20:58:21 +00:00
|
|
|
addgrbygid (struct database *db, int fd, request_header *req,
|
|
|
|
void *key, uid_t uid)
|
1998-10-18 15:16:22 +00:00
|
|
|
{
|
|
|
|
/* Search for the entry matching the key. Please note that we don't
|
|
|
|
look again in the table whether the dataset is now available. We
|
|
|
|
simply insert it. It does not matter if it is in there twice. The
|
|
|
|
pruning function only will look at the timestamp. */
|
|
|
|
int buflen = 256;
|
|
|
|
char *buffer = alloca (buflen);
|
|
|
|
struct group resultbuf;
|
|
|
|
struct group *grp;
|
|
|
|
gid_t gid = atol (key);
|
1999-06-11 20:58:21 +00:00
|
|
|
uid_t oldeuid = 0;
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1998-10-18 15:16:22 +00:00
|
|
|
if (debug_level > 0)
|
|
|
|
dbg_log (_("Haven't found \"%d\" in group cache!"), gid);
|
1998-01-31 08:39:55 +00:00
|
|
|
|
1999-06-11 20:58:21 +00:00
|
|
|
if (secure[grpdb])
|
|
|
|
{
|
|
|
|
oldeuid = geteuid ();
|
|
|
|
seteuid (uid);
|
|
|
|
}
|
|
|
|
|
1999-07-12 18:11:40 +00:00
|
|
|
while (__getgrgid_r (gid, &resultbuf, buffer, buflen, &grp) != 0
|
1998-10-18 15:16:22 +00:00
|
|
|
&& errno == ERANGE)
|
1998-01-31 08:39:55 +00:00
|
|
|
{
|
1998-10-18 15:16:22 +00:00
|
|
|
errno = 0;
|
|
|
|
buflen += 256;
|
|
|
|
buffer = alloca (buflen);
|
1998-01-31 08:39:55 +00:00
|
|
|
}
|
|
|
|
|
1999-06-11 20:58:21 +00:00
|
|
|
if (secure[grpdb])
|
|
|
|
seteuid (oldeuid);
|
|
|
|
|
|
|
|
cache_addgr (db, fd, req, key, grp, uid);
|
1998-01-31 08:39:55 +00:00
|
|
|
}
|