Commit graph

18 commits

Author SHA1 Message Date
Sebastian Pipping b884d88626 Fix compilation on Linux
Symptom with GCC 11:
> gcc-11 -std=c99 -Wextra -pedantic -Wall -O2 -DUSE_PAM -DDOAS_CONF=\"/etc/doas.conf\"  -D_GNU_SOURCE -include compat/compat.h -Icompat  -c -o env.o env.c
> env.c: In function ‘createenv’:
> env.c:139:37: error: conflicting types for ‘environ’; have ‘const char **’
>   139 |                 extern const char **environ;
>       |                                     ^~~~~~~

Symptom with Clang 17:
> clang-17 -std=c99 -Wextra -pedantic -Wall -O2 -DUSE_PAM -DDOAS_CONF=\"/etc/doas.conf\"  -D_GNU_SOURCE -include compat/compat.h -Icompat  -c -o env.o env.c
> env.c:139:23: error: redeclaration of 'environ' with a different type: 'const char **' vs 'char **'
>                 extern const char **environ;
>                                     ^

Related:
https://sourceforge.net/p/predef/wiki/OperatingSystems/#linux-kernel
2023-03-16 22:06:49 +01:00
Lucas Holt 5e7dab5420 Add MidnightBSD support. 2021-09-13 15:56:17 -04:00
Jesse Smith 014d8655fe Revert keeping LANG variable of original user when switching to
another user. LANG is not kept unless explicitly passed in the doas.conf file.
2021-06-03 11:47:42 -03:00
Jesse Smith 2299d4967d Make sure LANG environment variable is copied over to the target
user from the original, if it is defined. Avoids switching languages
on the original user by surprise.
2021-06-01 14:09:28 -03:00
Jesse Smith ab3ae5ad41 On FreeBSD limits set by the user's class (in /etc/login.conf) would
not be respected when running doas. The default class would always
be used, ignoring both the classing class and the target user's class.

This came about because FreeBSD has a "class" field in the password
structure, but other supported systems like Linux do not. doas.c and
env.c have been patched to support FreeBSD's class field in the password
structure. Login class limits are now respected.
2021-05-30 12:27:44 -03:00
Jesse Smith a006f46031 On some platforms (seemingly Linux and macOS) it is possible for
repeated calls to getpwuid() can over-write the original struct passwd
strucuture. This can lead to the original user's environment data
being overwritten by the target user's, even when "keepenv" is
specified in the doas.conf file.

We now do a deep copy of the original and target users' struct passwd
information to avoid over-writting the original on platforms where libc
uses a static area for all calls.
2019-12-27 22:10:57 -04:00
Jesse Smith 705dd9ce24 Reorganized compatibility code and Makefile.
- amalleo25
Provided cleaner fix for crash when user/command has
no valid match in the doas.conf file.
- amalleo25
Removed option to match UID with -u flag. Provided
usernames must now match a username, not UID. This was
ambigious if a user had a numeric username.
- Jesse
2019-09-10 13:56:32 -03:00
Jesse Smith 8e9c2bde06 Removed the transfer of most environment variables, such as USER, HOME,
and PATH from the original user to the target user. This could cause
files in the wrogn path or home directory to be read (or written to),
which resulted in potential security problems.

This has been changed so that only DISPLAY and TERM are passed to the
new environment. This is fine for running command line programs. When
GUI programs need to be run, "keepenv" can be added to the user's
doas.conf entry. This results in variables like HOME being copied
to the target user, allowing GUI programs to run.

Many thanks to Sander Bos for reporting this issue and explaining
how it can be exploited.

This commit also adds the ability to pass a customized PATH to
target users. The new PATH can be set at compile time in the
Makefile. The default path is provided in the Makefile and commented
out.
2019-08-03 17:39:15 -03:00
Jesse Smith fd79e385d7 Minor fixes to avoid compiling error on FreeBSD following Linux fixes. 2019-03-10 19:22:09 -03:00
Jesse Smith c8cb4d999e Avoid echoing stdin when output is piped to doas.
Fix asprintf() compile warning when building on Linux.
2019-03-10 19:11:40 -03:00
Jesse Smith 31f072078a Merge branch 'katakk-up' Brings us up to speed with OpenBSD 5.9. 2017-02-17 11:25:54 -04:00
Antonio Huete Jimenez 89ef570890 Fix build for DragonFly BSD
Until our sys/tree.h gets synced.
2017-02-15 11:33:34 +01:00
katakk 453102110a Merge, update from OpenBSD 2017-01-24 01:12:56 +09:00
Jesse Smith cdf69cb5f5 This commit allows doas to compile on Linux. Does not authenticate yet. 2016-06-26 11:41:31 -03:00
Tobias Kortkamp 64ab988d34 Change realloc() back to reallocarray() 2016-06-24 13:29:08 +02:00
User Jesse e6f145622d Removed unused reallocarr.c file and removed references to it from Makefile.
Fixed typo in parse.y which used + instead of * when calculating memory usage.
2016-06-22 22:59:03 +00:00
Jesse Smith d55af6cdf4 This is the initial port of doas to FreeBSD. It compiles, installs and works.
Could probably use a clean-up, but this code is functional on FreeBSD 10.3.
2016-06-22 12:21:34 -03:00
Jesse Smith cb8d475985 Initial upload from OpenBSD
This is the initial upload from OpenBSD. Kept for history and comparision with future releases.
2016-06-22 12:17:53 -03:00