id.h revision 64802
131921Sbrian/*- 231921Sbrian * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org> 331921Sbrian * All rights reserved. 431921Sbrian * 531921Sbrian * Redistribution and use in source and binary forms, with or without 631921Sbrian * modification, are permitted provided that the following conditions 731921Sbrian * are met: 831921Sbrian * 1. Redistributions of source code must retain the above copyright 931921Sbrian * notice, this list of conditions and the following disclaimer. 1031921Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1131921Sbrian * notice, this list of conditions and the following disclaimer in the 1231921Sbrian * documentation and/or other materials provided with the distribution. 1331921Sbrian * 1431921Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1531921Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1631921Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1731921Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1831921Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1931921Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2031921Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2131921Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2231921Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2331921Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2431921Sbrian * SUCH DAMAGE. 2531921Sbrian * 2650479Speter * $FreeBSD: head/usr.sbin/ppp/id.h 64802 2000-08-18 00:01:44Z brian $ 2731061Sbrian */ 2831061Sbrian 2964802Sbrian#ifndef NOSUID 3033603Sbrianstruct utmp; 3136285Sbrianstruct sockaddr_un; 3233603Sbrian 3331061Sbrianextern void ID0init(void); 3431061Sbrianextern uid_t ID0realuid(void); 3531061Sbrianextern int ID0ioctl(int, unsigned long, void *); 3631061Sbrianextern int ID0unlink(const char *); 3731061Sbrianextern int ID0socket(int, int, int); 3831061Sbrianextern FILE *ID0fopen(const char *, const char *); 3936285Sbrianextern int ID0open(const char *, int, ...); 4032025Sbrianextern int ID0write(int, const void *, size_t); 4131061Sbrianextern int ID0uu_lock(const char *); 4236450Sbrianextern int ID0uu_lock_txfr(const char *, pid_t); 4331061Sbrianextern int ID0uu_unlock(const char *); 4433603Sbrianextern void ID0login(struct utmp *); 4552487Sbrianextern void ID0logout(const char *, int); 4636285Sbrianextern int ID0bind_un(int, const struct sockaddr_un *); 4736285Sbrianextern int ID0connect_un(int, const struct sockaddr_un *); 4836467Sbrianextern int ID0kill(pid_t, int); 4953241Sbrian#if defined(__FreeBSD__) && !defined(NOKLDLOAD) 5051525Sbrianextern int ID0kldload(const char *); 5151525Sbrian#endif 5253535Sbrian#ifndef NONETGRAPH 5353535Sbrianextern int ID0NgMkSockNode(const char *, int *, int *); 5453535Sbrian#endif 5564802Sbrian#else /* NOSUID */ 5664802Sbrian#define ID0init() 5764802Sbrian#define ID0realuid() (0) 5864802Sbrian#define ID0ioctl ioctl 5964802Sbrian#define ID0unlink unlink 6064802Sbrian#define ID0socket socket 6164802Sbrian#define ID0fopen fopen 6264802Sbrian#define ID0open open 6364802Sbrian#define ID0write write 6464802Sbrian#define ID0uu_lock uu_lock 6564802Sbrian#define ID0uu_lock_txfr uu_lock_txfr 6664802Sbrian#define ID0uu_unlock uu_unlock 6764802Sbrian#define ID0login(u) \ 6864802Sbrian do { \ 6964802Sbrian if (logout((u)->ut_line)) \ 7064802Sbrian logwtmp((u)->ut_line, "", ""); \ 7164802Sbrian login(u); \ 7264802Sbrian } while (0) 7364802Sbrian#define ID0logout(dev, no) \ 7464802Sbrian do { \ 7564802Sbrian struct utmp ut; \ 7664802Sbrian strncpy(ut.ut_line, dev, sizeof ut.ut_line - 1); \ 7764802Sbrian ut.ut_line[sizeof ut.ut_line - 1] = '\0'; \ 7864802Sbrian if (no || logout(ut.ut_line)) \ 7964802Sbrian logwtmp(ut.ut_line, "", ""); \ 8064802Sbrian } while (0) 8164802Sbrian#define ID0bind_un(s, n) bind(s, (const struct sockaddr *)(n), sizeof *(n)) 8264802Sbrian#define ID0connect_un(s, n) \ 8364802Sbrian connect(s, (const struct sockaddr *)(n), sizeof *(n)) 8464802Sbrian#define ID0kill kill 8564802Sbrian#if defined(__FreeBSD__) && !defined(NOKLDLOAD) 8664802Sbrian#define ID0kldload kldload 8764802Sbrian#endif 8864802Sbrian#ifndef NONETGRAPH 8964802Sbrian#define ID0NgMkSockNode NgMkSockNode 9064802Sbrian#endif 9164802Sbrian#endif 92