]> granicus.if.org Git - sudo/blob - plugins/sudoers/stubs.c
a594b1f481b83b13fd83d1e11ff9fc0eb887b466
[sudo] / plugins / sudoers / stubs.c
1 /*
2  * Copyright (c) 2018 Todd C. Miller <Todd.Miller@sudo.ws>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 /*
18  * This is an open source non-commercial project. Dear PVS-Studio, please check it.
19  * PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
20  */
21
22 /*
23  * Stub versions of functions needed by the parser.
24  * Required to link cvtsudoers and visudo.
25  */
26
27 #include <config.h>
28
29 #include <sys/types.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #ifdef HAVE_STRING_H
33 # include <string.h>
34 #endif /* HAVE_STRING_H */
35 #ifdef HAVE_STRINGS_H
36 # include <strings.h>
37 #endif /* HAVE_STRINGS_H */
38
39 #include <netinet/in.h>
40 #include <arpa/inet.h>
41
42 #include "sudoers.h"
43 #include "interfaces.h"
44
45 /* STUB */
46 bool
47 init_envtables(void)
48 {
49     return true;
50 }
51
52 /* STUB */
53 bool
54 user_is_exempt(void)
55 {
56     return false;
57 }
58
59 /* STUB */
60 void
61 sudo_setspent(void)
62 {
63     return;
64 }
65
66 /* STUB */
67 void
68 sudo_endspent(void)
69 {
70     return;
71 }
72
73 /* STUB */
74 int
75 group_plugin_query(const char *user, const char *group, const struct passwd *pw)
76 {
77     return false;
78 }
79
80 /* STUB */
81 struct interface_list *
82 get_interfaces(void)
83 {
84     static struct interface_list dummy = SLIST_HEAD_INITIALIZER(interfaces);
85     return &dummy;
86 }
87
88 /*
89  * Look up the hostname and set user_host and user_shost.
90  */
91 void
92 get_hostname(void)
93 {
94     char *cp;
95     debug_decl(get_hostname, SUDOERS_DEBUG_UTIL)
96
97     if ((user_host = sudo_gethostname()) != NULL) {
98         if ((cp = strchr(user_host, '.'))) {
99             *cp = '\0';
100             if ((user_shost = strdup(user_host)) == NULL)
101                 sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
102             *cp = '.';
103         } else {
104             user_shost = user_host;
105         }
106     } else {
107         user_host = user_shost = strdup("localhost");
108         if (user_host == NULL)
109             sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
110     }
111     user_runhost = user_host;
112     user_srunhost = user_shost;
113
114     debug_return;
115 }