1 /*
2 * SPDX-License-Identifier: ISC
3 *
4 * Copyright (c) 2014 Todd C. Miller <Todd.Miller@sudo.ws>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #include <config.h>
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24
25 #include "sudo_compat.h"
26 #include "sudo_util.h"
27
28 sudo_dso_public int main(int argc, char *argv[]);
29
30 /*
31 * Test that getprogname() returns the expected result.
32 * On some systems (AIX), we may have issues with symbolic links.
33 */
34
35 int
main(int argc,char * argv[])36 main(int argc, char *argv[])
37 {
38 char *progbase = "progname_test";
39
40 if (argc > 0)
41 progbase = sudo_basename(argv[0]);
42 initprogname(progbase);
43
44 /* Make sure getprogname() matches basename of argv[0]. */
45 if (strcmp(getprogname(), progbase) != 0) {
46 printf("%s: FAIL: incorrect program name \"%s\"\n",
47 progbase, getprogname());
48 exit(EXIT_FAILURE);
49 }
50
51 exit(EXIT_SUCCESS);
52 }
53