Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add necessary support routines for login.conf.
details: https://anonhg.NetBSD.org/src/rev/b8e8433e0349
branches: trunk
changeset: 480417:b8e8433e0349
user: mjl <mjl%NetBSD.org@localhost>
date: Wed Jan 12 05:02:10 2000 +0000
description:
Add necessary support routines for login.conf.
diffstat:
distrib/sets/lists/base/shl.mi | 4 +-
include/Makefile | 5 +-
include/login_cap.h | 79 ++++
include/util.h | 3 +-
lib/libutil/Makefile | 22 +-
lib/libutil/login_cap.3 | 220 +++++++++++
lib/libutil/login_cap.c | 769 +++++++++++++++++++++++++++++++++++++++++
lib/libutil/securepath.3 | 57 +++
lib/libutil/securepath.c | 67 +++
lib/libutil/shlib_version | 4 +-
share/man/man5/Makefile | 4 +-
share/man/man5/login.conf.5 | 308 ++++++++++++++++
12 files changed, 1528 insertions(+), 14 deletions(-)
diffs (truncated from 1645 to 300 lines):
diff -r c03e68c44d5a -r b8e8433e0349 distrib/sets/lists/base/shl.mi
--- a/distrib/sets/lists/base/shl.mi Wed Jan 12 04:49:56 2000 +0000
+++ b/distrib/sets/lists/base/shl.mi Wed Jan 12 05:02:10 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.50 1999/12/23 10:23:34 kleink Exp $
+# $NetBSD: shl.mi,v 1.51 2000/01/12 05:02:12 mjl Exp $
./usr/lib/libamu.so.1.1
./usr/lib/libbfd.so.3.0
./usr/lib/libbz2.so.0.0
@@ -24,6 +24,6 @@
./usr/lib/libtermcap.so.0.1
./usr/lib/libtermlib.so.0.1
./usr/lib/libusb.so.0.0
-./usr/lib/libutil.so.5.1
+./usr/lib/libutil.so.5.2
./usr/lib/libwrap.so.0.2
./usr/lib/libz.so.0.2
diff -r c03e68c44d5a -r b8e8433e0349 include/Makefile
--- a/include/Makefile Wed Jan 12 04:49:56 2000 +0000
+++ b/include/Makefile Wed Jan 12 05:02:10 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.81 2000/01/10 16:58:37 kleink Exp $
+# $NetBSD: Makefile,v 1.82 2000/01/12 05:02:11 mjl Exp $
# @(#)Makefile 8.2 (Berkeley) 1/4/94
SRCTOP= ..
@@ -11,7 +11,8 @@
INCS= a.out.h ar.h assert.h bitstring.h bm.h cpio.h ctype.h db.h dirent.h \
disktab.h dlfcn.h err.h errno.h fmtmsg.h fnmatch.h fstab.h fts.h \
glob.h grp.h hesiod.h ieeefp.h iso646.h kvm.h langinfo.h libgen.h \
- limits.h link.h link_aout.h link_elf.h locale.h malloc.h math.h md4.h \
+ limits.h link.h link_aout.h link_elf.h locale.h \
+ login_cap.h malloc.h math.h md4.h \
memory.h mpool.h ndbm.h netdb.h netgroup.h nlist.h nl_types.h \
nsswitch.h paths.h pwd.h ranlib.h re_comp.h regex.h regexp.h \
resolv.h rmt.h search.h setjmp.h sgtty.h signal.h stab.h stddef.h \
diff -r c03e68c44d5a -r b8e8433e0349 include/login_cap.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/login_cap.h Wed Jan 12 05:02:10 2000 +0000
@@ -0,0 +1,79 @@
+/* $NetBSD: login_cap.h,v 1.1 2000/01/12 05:02:11 mjl Exp $ */
+
+/*-
+ * Copyright (c) 1995,1997 Berkeley Software Design, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Berkeley Software Design,
+ * Inc.
+ * 4. The name of Berkeley Software Design, Inc. may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * BSDI login_cap.h,v 2.10 1997/08/07 21:35:19 prb Exp
+ */
+
+#ifndef _LOGIN_CAP_H_
+#define _LOGIN_CAP_H_
+
+#define LOGIN_DEFCLASS "default"
+#define LOGIN_DEFSERVICE "login"
+#define LOGIN_DEFUMASK 022
+#define _PATH_LOGIN_CONF "/etc/login.conf"
+
+#define LOGIN_SETGROUP 0x0001 /* Set group */
+#define LOGIN_SETLOGIN 0x0002 /* Set login */
+#define LOGIN_SETPATH 0x0004 /* Set path */
+#define LOGIN_SETPRIORITY 0x0008 /* Set priority */
+#define LOGIN_SETRESOURCES 0x0010 /* Set resource limits */
+#define LOGIN_SETUMASK 0x0020 /* Set umask */
+#define LOGIN_SETUSER 0x0040 /* Set user */
+#define LOGIN_SETALL 0x007f /* Set all. */
+
+typedef struct {
+ char *lc_class;
+ char *lc_cap;
+ char *lc_style;
+} login_cap_t;
+
+#include <sys/cdefs.h>
+__BEGIN_DECLS
+struct passwd;
+
+login_cap_t *login_getclass __P((char *));
+void login_close __P((login_cap_t *));
+int login_getcapbool __P((login_cap_t *, char *, u_int));
+quad_t login_getcapnum __P((login_cap_t *, char *, quad_t, quad_t));
+quad_t login_getcapsize __P((login_cap_t *, char *, quad_t, quad_t));
+char *login_getcapstr __P((login_cap_t *, char *, char *, char *));
+quad_t login_getcaptime __P((login_cap_t *, char *, quad_t, quad_t));
+
+int secure_path __P((char *));
+int setclasscontext __P((char *, u_int));
+int setusercontext __P((login_cap_t *, struct passwd *, uid_t, u_int));
+
+__END_DECLS
+
+#endif
+
diff -r c03e68c44d5a -r b8e8433e0349 include/util.h
--- a/include/util.h Wed Jan 12 04:49:56 2000 +0000
+++ b/include/util.h Wed Jan 12 05:02:10 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: util.h,v 1.14 1999/06/12 18:06:19 christos Exp $ */
+/* $NetBSD: util.h,v 1.15 2000/01/12 05:02:11 mjl Exp $ */
/*-
* Copyright (c) 1995
@@ -86,6 +86,7 @@
int ttyunlock __P((const char *));
int ttyaction __P((const char *, const char *, const char *));
char *ttymsg __P((struct iovec *, int, const char *, int));
+int secure_path __P((char *));
__END_DECLS
#endif /* !_UTIL_H_ */
diff -r c03e68c44d5a -r b8e8433e0349 lib/libutil/Makefile
--- a/lib/libutil/Makefile Wed Jan 12 04:49:56 2000 +0000
+++ b/lib/libutil/Makefile Wed Jan 12 05:02:10 2000 +0000
@@ -1,19 +1,31 @@
-# $NetBSD: Makefile,v 1.23 1999/07/02 15:49:12 simonb Exp $
+# $NetBSD: Makefile,v 1.24 2000/01/12 05:02:10 mjl Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
LIB= util
CPPFLAGS+=-DLIBC_SCCS
-SRCS= fparseln.c getmaxpartitions.c getrawpartition.c login.c login_tty.c \
+SRCS= fparseln.c getmaxpartitions.c getrawpartition.c \
+ login.c login_cap.c login_tty.c \
logout.c logwtmp.c opendisk.c passwd.c pw_scan.c pidfile.c pidlock.c \
- pty.c ttyaction.c ttymsg.c
+ pty.c securepath.c ttyaction.c ttymsg.c
-MAN= fparseln.3 getmaxpartitions.3 getrawpartition.3 login.3 opendisk.3 \
- openpty.3 pidfile.3 pidlock.3 pw_init.3 pw_lock.3 ttyaction.3 ttymsg.3
+MAN= fparseln.3 getmaxpartitions.3 getrawpartition.3 \
+ login.3 login_cap.3 opendisk.3 \
+ openpty.3 pidfile.3 pidlock.3 pw_init.3 pw_lock.3 \
+ securepath.3 ttyaction.3 ttymsg.3
.PATH: ${.CURDIR}/../libc/gen
MLINKS+=login.3 logout.3
MLINKS+=login.3 logwtmp.3
+MKLINKS+=login_cap.3 login_getclass.3
+MKLINKS+=login_cap.3 login_getcapbool.3
+MKLINKS+=login_cap.3 login_getcapnum.3
+MKLINKS+=login_cap.3 login_getcapsize.3
+MKLINKS+=login_cap.3 login_getcapstr.3
+MKLINKS+=login_cap.3 login_getcaptime.3
+MKLINKS+=login_cap.3 login_close.3
+MKLINKS+=login_cap.3 setclasscontext.3
+MKLINKS+=login_cap.3 setusercontext.3
MLINKS+=openpty.3 login_tty.3
MLINKS+=openpty.3 forkpty.3
MLINKS+=pw_init.3 pw_edit.3
diff -r c03e68c44d5a -r b8e8433e0349 lib/libutil/login_cap.3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libutil/login_cap.3 Wed Jan 12 05:02:10 2000 +0000
@@ -0,0 +1,220 @@
+.\" $NetBSD: login_cap.3,v 1.1 2000/01/12 05:02:10 mjl Exp $
+.\"
+.\" Copyright (c) 1996,1997 Berkeley Software Design, Inc. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Berkeley Software Design,
+.\" Inc.
+.\" 4. The name of Berkeley Software Design, Inc. may not be used to endorse
+.\" or promote products derived from this software without specific prior
+.\" written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" BSDI login_cap.3,v 1.4 1997/11/07 16:22:27 jch Exp
+.\"
+.Dd "July 16, 1996"
+.Dt LOGIN_CAP 3
+.Os
+.Sh NAME
+.Nm login_getclass ,
+.Nm login_getcapbool ,
+.Nm login_getcapnum ,
+.Nm login_getcapsize ,
+.Nm login_getcapstr ,
+.Nm login_getcaptime ,
+.Nm login_close ,
+.Nm setclasscontext ,
+.Nm setusercontext
+.Nd query login.conf database about a user class
+.Sh LIBRARY
+.Lb libutil
+.Sh SYNOPSIS
+.Fd #include <login_cap.h>
+.Ft login_cap_t *
+.Fn login_getclass "char *class"
+.Ft int
+.Fn login_getcapbool "login_cap_t *lc" "char *cap" "u_int def"
+.Ft quad_t
+.Fn login_getcapnum "login_cap_t *lc" "char *cap" "quad_t def" "quad_t err"
+.Ft quad_t
+.Fn login_getcapsize "login_cap_t *lc" "char *cap" "quad_t def" "quad_t err"
+.Ft char *
+.Fn login_getcapstr "login_cap_t *lc" "char *cap" "char *def" "char *err"
+.Ft quad_t
+.Fn login_getcaptime "login_cap_t *lc" "char *cap" "quad_t def" "quad_t err"
+.Ft void
+.Fn login_close "login_cap_t *lc"
+.Ft int
+.Fn setclasscontext "char *class" "u_int flags"
+.Ft int
+.Fn setusercontext "login_cap_t *lc" "struct passwd *pwd" "uid_t uid" "u_int flags"
+.Sh DESCRIPTION
+The
+.Fn login_getclass
+function extracts the entry specified by
+.Ar class
+(or
+.Li default
+if
+.Ar class
+is NULL or the empty string)
+from
+.Pa /etc/login.conf
+(see
+.Xr login.conf 5 ) .
+If the entry is found, a
+.Li login_cap_t
+pointer is returned.
+NULL is returned if the user class is not found.
+When the
+.Li login_cap_t
+structure is no longer needed, is should be freed by the
+.Fn login_close
+function.
+.Pp
+Once
+.Ar lc
+has been returned by
+.Fn login_getclass ,
+any of the other
+.Fn login_*
+functions may be called.
+.Pp
+The
+.Fn login_getcapnum ,
+.Fn login_getcapsize ,
+.Fn login_getcapstr ,
+and
+.Fn login_getcaptime
+functions all query the database entry for a field named
+.Ar cap .
+If the field is found, its value is returned. If the field is not
+found, the value specified by
+.Ar def
+is returned.
+If an error is encountered while trying to find the field,
+.Ar err
+is returned.
+See
+.Xr login.conf 5
+for a discussion of the various textual forms the value may take.
Home |
Main Index |
Thread Index |
Old Index