mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 01:30:30 -04:00
setclassenvironment: trim leading spaces in variable names
Trim leading spaces in variable names when the list is e.g.
pretty-formatted in /etc/login.conf or ~/.login_conf.
PR: 247947
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D25649
(cherry picked from commit eeaf9d562f)
This commit is contained in:
parent
bda3bf09d8
commit
c6dcae2dfa
1 changed files with 7 additions and 2 deletions
|
|
@ -231,12 +231,17 @@ setclassenvironment(login_cap_t *lc, const struct passwd * pwd, int paths)
|
|||
while (*set_env != NULL) {
|
||||
char *p = strchr(*set_env, '=');
|
||||
|
||||
if (p != NULL) { /* Discard invalid entries */
|
||||
if (p != NULL && p != *set_env) { /* Discard invalid entries */
|
||||
const char *ep;
|
||||
char *np;
|
||||
|
||||
*p++ = '\0';
|
||||
/* Strip leading spaces from variable name */
|
||||
ep = *set_env;
|
||||
while (*ep == ' ' || *ep == '\t')
|
||||
ep++;
|
||||
if ((np = substvar(p, pwd, hlen, pch, nlen)) != NULL) {
|
||||
setenv(*set_env, np, 1);
|
||||
setenv(ep, np, 1);
|
||||
free(np);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue