zsh-workers
 help / color / mirror / code / Atom feed
From: dana <dana@dana.is>
To: Zsh workers <zsh-workers@zsh.org>
Subject: [PATCH/RFC] Don't source .zlogout if privileged
Date: Sat, 26 Jan 2019 12:13:18 -0600	[thread overview]
Message-ID: <448CAC98-5073-423F-B658-56580F4877FA@dana.is> (raw)

I noticed whilst formulating a reply to users/23847 that the shell still
sources the user .zlogout even when the privileged option is set. The ML
archive doesn't go back far enough for me to see what the rationale was for
that, but i'm guessing maybe it's because the feature was borrowed from ksh,
and ksh doesn't have a logout file. (In fact, the option didn't originally
affect zsh-specific init files at all, since it was only used for ksh
emulation.) But shouldn't the same logic apply? Or is there a particular
reason to treat it differently?

(If it *is* desirable behaviour, i'll send a different patch documenting that
more explicitly)

dana


diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index bc182eb7b..379ee2a06 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -2377,7 +2377,7 @@ for failure and act accordingly, for example:
 
 example(unsetopt privileged || exit)
 
-The tt(PRIVILEGED) option disables sourcing user startup files.
+The tt(PRIVILEGED) option disables sourcing user startup/shutdown files.
 If zsh is invoked as `tt(sh)' or `tt(ksh)' with this option set,
 tt(/etc/suid_profile) is sourced (after tt(/etc/profile) on interactive
 shells). Sourcing tt(~/.profile) is disabled and the contents of the
diff --git a/Src/builtin.c b/Src/builtin.c
index 8dcdcc024..01fca6f7c 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5791,7 +5791,7 @@ zexit(int val, int from_where)
 	    saveandpophiststack(1, writeflags);
 	    savehistfile(NULL, 1, writeflags);
 	}
-	if (islogin && !subsh) {
+	if (islogin && !subsh && unset(PRIVILEGED)) {
 	    sourcehome(".zlogout");
 #ifdef GLOBAL_ZLOGOUT
 	    if (isset(RCS) && isset(GLOBALRCS))


                 reply	other threads:[~2019-01-26 18:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=448CAC98-5073-423F-B658-56580F4877FA@dana.is \
    --to=dana@dana.is \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).