Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.sbin / pkg_install / sign / extern.h
CommitLineData
984263bc
MD
1/* $FreeBSD: src/usr.sbin/pkg_install/sign/extern.h,v 1.1.2.2 2001/05/17 12:33:39 sobomax Exp $ */
2/* $OpenBSD: extern.h,v 1.3 1999/10/07 16:30:32 espie Exp $ */
3/*-
4 * Copyright (c) 1999 Marc Espie.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Marc Espie for the OpenBSD
17 * Project.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
23 * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/*
33 * Convention: all functions that operate on a FILE * also take a filename
34 * for diagnostic purposes. The file can be connected to a pipe, so
35 * - don't rewind
36 * - don't reopen from filename.
37 */
38
39struct mygzip_header;
40struct signature;
41
42/* main.c */
43extern int verbose;
44extern int quiet;
45extern char *userkey;
46
47/* common.c */
48extern int read_header_and_diagnose __P((FILE *file, \
49 /*@out@*/struct mygzip_header *h, /*@null@*/struct signature **sign, \
50 const char *filename));
51extern int reap __P((pid_t pid));
52
53/* sign.c */
54extern int sign __P((/*@observer@*/const char *filename, int type, \
55 /*@null@*/const char *userid, char *envp[]));
56
57/* check.c */
58extern int check_signature __P((/*@dependent@*/FILE *file, \
59 /*@null@*/const char *userid, char *envp[], \
60 /*@observer@*/const char *filename));
61
62#define PKG_BADSIG 0
63#define PKG_GOODSIG 1
64#define PKG_UNSIGNED 2
65#define PKG_SIGNED 4
66#define PKG_SIGERROR 8
67#define PKG_SIGUNKNOWN 16
68
69typedef /*@observer@*/char *pchar;
70
71#define MAXID 512
72/* sha1.c */
73#define SHA1_DB_NAME "/var/db/pkg/SHA1"
74
75extern void *new_sha1_checker __P((struct mygzip_header *h, \
76 struct signature *sign, const char *userid, char *envp[], \
77 const char *filename));
78
79extern void sha1_add __P((void *arg, const char *buffer, \
80 size_t length));
81
82extern int sha1_sign_ok __P((void *arg));
83
84extern int retrieve_sha1_marker __P((const char *filename, \
85 struct signature **sign, const char *userid));
86
87/* x509.c */
88#define X509_DB_NAME "/var/db/pkg/X509"
89
90extern void *new_x509_checker __P((struct mygzip_header *h, \
91 struct signature *sign, const char *userid, char *envp[], \
92 const char *filename));
93
94extern void x509_add __P((void *arg, const char *buffer, \
95 size_t length));
96
97extern int x509_sign_ok __P((void *arg));
98
99extern int retrieve_x509_marker __P((const char *filename, \
100 struct signature **sign, const char *userid));