From eb8dd9dca1228af0cd132f515509051ecfabf6f6 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Mon, 14 Apr 2025 17:32:06 +0000 Subject: This commit was manufactured by cvs2git to create tag 'tb_20250414'. --- src/regress/lib/libc/env/Makefile | 5 -- src/regress/lib/libc/env/envtest.c | 122 ------------------------------------- 2 files changed, 127 deletions(-) delete mode 100644 src/regress/lib/libc/env/Makefile delete mode 100644 src/regress/lib/libc/env/envtest.c (limited to 'src/regress/lib/libc/env') diff --git a/src/regress/lib/libc/env/Makefile b/src/regress/lib/libc/env/Makefile deleted file mode 100644 index 92e04369f4..0000000000 --- a/src/regress/lib/libc/env/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $OpenBSD: Makefile,v 1.1 2010/08/23 22:34:37 millert Exp $ - -PROG= envtest - -.include diff --git a/src/regress/lib/libc/env/envtest.c b/src/regress/lib/libc/env/envtest.c deleted file mode 100644 index 79a5c0655f..0000000000 --- a/src/regress/lib/libc/env/envtest.c +++ /dev/null @@ -1,122 +0,0 @@ -/* $OpenBSD: envtest.c,v 1.3 2021/09/01 09:26:32 jasper Exp $ */ - -/* - * Copyright (c) 2010 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -#include -#include -#include -#include - -extern char **environ; - -static int -count_instances(const char *name) -{ - int count = 0; - size_t namelen; - char **ep; - - namelen = strlen(name); - for (ep = environ; *ep != NULL; ep++) { - if (strncmp(name, *ep, namelen) == 0 && (*ep)[namelen] == '=') - count++; - } - - return count; -} - -static void -fake_env(void) -{ - static char *fakenv[7]; - - fakenv[0] = "HOME=/root"; - fakenv[1] = "USER=root"; - fakenv[2] = "LOGNAME=root"; - fakenv[3] = "SHELL=/bin/sh"; - fakenv[4] = "USER=root"; - fakenv[5] = NULL; - - environ = fakenv; -} - -int -main(int argc, char *argv[]) -{ - char *buf; - int n, failures = 0; - size_t len, bufsize; - - fake_env(); - n = count_instances("USER"); - if (n != 2) { - fprintf(stderr, "initial: %d instances of USER, expected %d\n", - n, 2); - failures++; - } - - if (unsetenv("USER") != 0) { - fprintf(stderr, "unsetenv: failed to remove USER\n"); - failures++; - } - n = count_instances("USER"); - if (n != 0) { - fprintf(stderr, "unsetenv: %d instances of USER, expected %d\n", - n, 0); - failures++; - } - - fake_env(); - if (setenv("USER", "nobody", 0) != 0) { - fprintf(stderr, "setenv: failed to set USER\n"); - failures++; - } - n = count_instances("USER"); - if (n != 2) { - fprintf(stderr, "setenv: %d instances of USER, expected %d\n", - n, 2); - failures++; - } - - fake_env(); - if (setenv("USER", "nobody", 1) != 0) { - fprintf(stderr, "setenv: failed to set USER\n"); - failures++; - } - n = count_instances("USER"); - if (n != 1) { - fprintf(stderr, "setenv: %d instances of USER, expected %d\n", - n, 1); - failures++; - } - - fake_env(); - if (putenv("USER=nobody") != 0) { - fprintf(stderr, "putenv: failed to set USER\n"); - failures++; - } - n = count_instances("USER"); - if (n != 1) { - fprintf(stderr, "putenv: %d instances of USER, expected %d\n", - n, 1); - failures++; - } - - return failures; -} -- cgit v1.2.3-55-g6feb