1*7e97ed9aSmillert /* $OpenBSD: util.h,v 1.38 2022/05/11 17:23:56 millert Exp $ */ 2ad69070aSdownsj /* $NetBSD: util.h,v 1.2 1996/05/16 07:00:22 thorpej Exp $ */ 3ad69070aSdownsj 4ad69070aSdownsj /*- 5ad69070aSdownsj * Copyright (c) 1995 6ad69070aSdownsj * The Regents of the University of California. All rights reserved. 7ad69070aSdownsj * Portions Copyright (c) 1996, Jason Downs. All rights reserved. 8ad69070aSdownsj * 9ad69070aSdownsj * Redistribution and use in source and binary forms, with or without 10ad69070aSdownsj * modification, are permitted provided that the following conditions 11ad69070aSdownsj * are met: 12ad69070aSdownsj * 1. Redistributions of source code must retain the above copyright 13ad69070aSdownsj * notice, this list of conditions and the following disclaimer. 14ad69070aSdownsj * 2. Redistributions in binary form must reproduce the above copyright 15ad69070aSdownsj * notice, this list of conditions and the following disclaimer in the 16ad69070aSdownsj * documentation and/or other materials provided with the distribution. 176580fee3Smillert * 3. Neither the name of the University nor the names of its contributors 18ad69070aSdownsj * may be used to endorse or promote products derived from this software 19ad69070aSdownsj * without specific prior written permission. 20ad69070aSdownsj * 21ad69070aSdownsj * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22ad69070aSdownsj * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23ad69070aSdownsj * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24ad69070aSdownsj * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25ad69070aSdownsj * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26ad69070aSdownsj * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27ad69070aSdownsj * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28ad69070aSdownsj * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29ad69070aSdownsj * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30ad69070aSdownsj * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31ad69070aSdownsj * SUCH DAMAGE. 32ad69070aSdownsj */ 33ad69070aSdownsj 34ad69070aSdownsj #ifndef _UTIL_H_ 35ad69070aSdownsj #define _UTIL_H_ 36ad69070aSdownsj 3751624001Smillert #include <sys/types.h> 38ad69070aSdownsj 39ad69070aSdownsj /* 4003d4f44bSjakob * fparseln() specific operation flags. 4103d4f44bSjakob */ 4203d4f44bSjakob #define FPARSELN_UNESCESC 0x01 4303d4f44bSjakob #define FPARSELN_UNESCCONT 0x02 4403d4f44bSjakob #define FPARSELN_UNESCCOMM 0x04 4503d4f44bSjakob #define FPARSELN_UNESCREST 0x08 4603d4f44bSjakob #define FPARSELN_UNESCALL 0x0f 4703d4f44bSjakob 4803d4f44bSjakob /* 49ad69070aSdownsj * opendev() specific operation flags. 50ad69070aSdownsj */ 51ad69070aSdownsj #define OPENDEV_PART 0x01 /* Try to open the raw partition. */ 5241c16d58Smillert #define OPENDEV_BLCK 0x04 /* Open block, not character device. */ 53ad69070aSdownsj 5451624001Smillert /* 5544946945Sderaadt * uu_lock(3) specific flags. 5651624001Smillert */ 5751624001Smillert #define UU_LOCK_INUSE (1) 5851624001Smillert #define UU_LOCK_OK (0) 5951624001Smillert #define UU_LOCK_OPEN_ERR (-1) 6051624001Smillert #define UU_LOCK_READ_ERR (-2) 6151624001Smillert #define UU_LOCK_CREAT_ERR (-3) 6251624001Smillert #define UU_LOCK_WRITE_ERR (-4) 6351624001Smillert #define UU_LOCK_LINK_ERR (-5) 6451624001Smillert #define UU_LOCK_TRY_ERR (-6) 6551624001Smillert #define UU_LOCK_OWNER_ERR (-7) 6651624001Smillert 6751624001Smillert /* 68f353b857Sian * fmt_scaled(3) specific flags. 69f353b857Sian */ 70f353b857Sian #define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */ 71f353b857Sian 72f353b857Sian /* 7351624001Smillert * stub struct definitions. 7451624001Smillert */ 7551624001Smillert struct __sFILE; 7651624001Smillert struct login_cap; 7751624001Smillert struct passwd; 7851624001Smillert struct termios; 7951624001Smillert struct utmp; 8051624001Smillert struct winsize; 8151624001Smillert 82ad69070aSdownsj __BEGIN_DECLS 83c72b5b24Smillert char *fparseln(struct __sFILE *, size_t *, size_t *, const char[3], int); 84c72b5b24Smillert void login(struct utmp *); 85c72b5b24Smillert int login_tty(int); 86c72b5b24Smillert int logout(const char *); 87c72b5b24Smillert void logwtmp(const char *, const char *, const char *); 8827ad9b61Smillert int opendev(const char *, int, int, char **); 89c72b5b24Smillert int pidfile(const char *); 90c72b5b24Smillert void pw_setdir(const char *); 91c72b5b24Smillert char *pw_file(const char *); 9203c79f70Snicm int pw_lock(int); 93c72b5b24Smillert int pw_mkdb(char *, int); 94c72b5b24Smillert int pw_abort(void); 95c72b5b24Smillert void pw_init(void); 96c72b5b24Smillert void pw_edit(int, const char *); 97c72b5b24Smillert void pw_prompt(void); 9846bc4394Smillert void pw_copy(int, int, const struct passwd *, const struct passwd *); 99c72b5b24Smillert int pw_scan(char *, struct passwd *, int *); 100*7e97ed9aSmillert __dead void pw_error(const char *, int, int); 101c2a62bf3Snicm int getptmfd(void); 10278fa49eaSmillert int openpty(int *, int *, char *, const struct termios *, 10378fa49eaSmillert const struct winsize *); 10478fa49eaSmillert int fdopenpty(int, int *, int *, char *, const struct termios *, 10578fa49eaSmillert const struct winsize *); 10603c79f70Snicm int opendisk(const char *, int, char *, size_t, int); 10778fa49eaSmillert pid_t forkpty(int *, char *, const struct termios *, const struct winsize *); 10878fa49eaSmillert pid_t fdforkpty(int, int *, char *, const struct termios *, 10978fa49eaSmillert const struct winsize *); 110c72b5b24Smillert int getmaxpartitions(void); 111c72b5b24Smillert int getrawpartition(void); 1123cf33643Smillert void login_fbtab(const char *, uid_t, gid_t); 113c72b5b24Smillert int login_check_expire(struct __sFILE *, struct passwd *, char *, int); 114c72b5b24Smillert char *readlabelfs(char *, int); 11503c79f70Snicm const char *uu_lockerr(int); 11603c79f70Snicm int uu_lock(const char *); 11703c79f70Snicm int uu_lock_txfr(const char *, pid_t); 11803c79f70Snicm int uu_unlock(const char *); 11903c79f70Snicm int fmt_scaled(long long, char *); 12003c79f70Snicm int scan_scaled(char *, long long *); 121cf1d0975Sjsing int isduid(const char *, int); 122410ca83dStedu int pkcs5_pbkdf2(const char *, size_t, const uint8_t *, size_t, 123410ca83dStedu uint8_t *, size_t, unsigned int); 124410ca83dStedu int bcrypt_pbkdf(const char *, size_t, const uint8_t *, size_t, 125410ca83dStedu uint8_t *, size_t, unsigned int); 12611dbc5f7Stedu 127ad69070aSdownsj __END_DECLS 128ad69070aSdownsj 129ad69070aSdownsj #endif /* !_UTIL_H_ */ 130