delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
X-Injected-Via-Gmane: | http://gmane.org/ |
To: | cygwin AT cygwin DOT com |
From: | Andrew DeFaria <ADeFaria AT Salira DOT com> |
Subject: | Re: seteuid and file ownership |
Date: | Thu, 20 Mar 2003 13:16:46 -0800 |
Lines: | 47 |
Message-ID: | <3E7A2FBE.6020006@Salira.com> |
References: | <F112Jj8a5wY5vMoWTeM0001b935 AT hotmail DOT com> |
Mime-Version: | 1.0 |
X-Complaints-To: | usenet AT main DOT gmane DOT org |
User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 |
X-Accept-Language: | en-us, en, ru, zh |
You might start by checking the status after the setuid call. Perhaps it failed. Vishal Jain wrote: > Hi, > I am making a seteuid() call to impersonate user "shweta". > Then I create a file. When I do ls -l on the file, it shows the owner as > "vishalj" which was the user before doing impersonation. > -rw-rw-rw- 1 vishalj mkgroup 0 Mar 20 12:50 shweta > Is this expected behaviour in cygwin? > I am attaching the code snippet- > > #include <windows.h> > #include <sys/cygwin.h> > #include <stdio.h> > #include <pwd.h> > > int main(int argc, char *argv[]){ > HANDLE token = INVALID_HANDLE_VALUE; > struct passwd *pw = NULL; > FILE *fp = NULL; > pw = getpwnam("shweta"); > token = cygwin_logon_user(pw, "shweta"); > if(token == INVALID_HANDLE_VALUE){ > printf("Login failed\n"); > } > cygwin_set_impersonation_token(token); > seteuid(pw->pw_uid); > fp = fopen("shweta", "w"); > if(fp == NULL){ > printf("could not open file for writing\n"); > } > fclose(fp); > } > > Thanks, > Vishal > > > > _________________________________________________________________ > MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. > http://join.msn.com/?page=features/virus > > -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |