zsh-workers
 help / color / mirror / code / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: zsh-workers@sunsite.dk, zsh-workers@sunsite.dk,
	zsh-workers@sunsite.dk, zsh-workers@sunsite.dk,
	lkml@vger.kernel.org
Subject: Linux 2.5 and Zsh bug
Date: Fri, 18 Oct 2002 13:59:22 -0700	[thread overview]
Message-ID: <3DB0762A.7070605@osdl.org> (raw)

When running zsh on a Linux 2.5 kernel, the prompt always has a hash 
sign '#' rather than the normal user '$'.  This probably happens because 
the shell function privasserted() is returning true for all users.  I 
know nothing about Posix capabilities but the zsh code for this looks 
suspicious.

Code in question:
------------------------------------------------------------
/* isolate zsh bug */
#include <stdio.h>
#include <sys/capability.h>

int
privasserted(void)
{
    if(!geteuid()) {
        printf("geteuid() is root\n");
        return 1;
    }
    else  {
        cap_t caps = cap_get_proc();
        if(caps) {
            printf("caps = %p\n", caps);
            /* POSIX doesn't define a way to test whether a capability set *
             * is empty or not.  Typical.  I hope this is 
conforming...    */
            cap_flag_value_t val;
            cap_value_t n;

            for(n = 0; !cap_get_flag(caps, n, CAP_EFFECTIVE, &val); n++) {
                if(val) {
                    printf("capability %#x is %d\n", n, val);
                    cap_free(caps); /* missing in original zsh code 
memory leak */
                    return 1;
                }
            }
            printf("last capability %#x\n", n);

            cap_free(caps);
        }
    }
    return 0;
}

int main(int argc, const char **argv) {
    printf("%s privledged\n", privasserted() ?  "Is" : "Not");
}

------------------------------------------------
On 2.4.18
caps = 0x8049844
last capability 0x1d
Not privledged

On 2.5.43
caps = 0x804a00c
capability 0 is 1
Is privledged




             reply	other threads:[~2002-10-18 20:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-18 20:59 Stephen Hemminger [this message]
2002-10-18 21:50 ` Clint Adams

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=3DB0762A.7070605@osdl.org \
    --to=shemminger@osdl.org \
    --cc=lkml@vger.kernel.org \
    --cc=zsh-workers@sunsite.dk \
    /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).