Re: file handling with fopen() and fclose()
- From: John Breen <locutus borg apana org au>
- To: gtk-list gnome org
- Subject: Re: file handling with fopen() and fclose()
- Date: 27 Feb 2002 13:18:51 +0800
On Wed, 2002-02-27 at 13:04, Valdis Kletnieks vt edu wrote:
> On Wed, 27 Feb 2002 12:53:53 +0800, John Breen <locutus borg apana org au> said:
>
> > fp=fopen("/etc/shadow");
>
> SYNOPSIS
> #include <stdio.h>
>
> FILE *fopen(const char *path, const char *mode);
sorry, the code is actually
fp = fopen("/etc/shadow", "r");
>
>
> Might want to pass a mode there, it would SIGSEGV pretty quickly otherwise.
>
> Also, note that /etc/shadow is probably only readable by root - which means
> that you're in for *LOADS* of security fun (you get to run set-UID, or
> run as root, or figure out how to use PAM on systems that support it).
the code's been compiled, and then
chgrp shadow executable
chmod g+s executable
which means that the app will be run if by a member of the shadow group,
which is the group on /etc/shadow, and has read-access to /etc/shadow.
>
> Personally, I think PAM is your best bet if you can use it.
I hadn't thought of PAM (and don't know how to use it in the context of
this app. anyway :( )
the thing is, it works ok for me in a console version, just won't work
in GTK+ - it seems to get to the first line using the file after fopen()
and close the app down totally.
oh well, time to climb the ol' learning curve again. shame, 'cause i
wanted to get this bit out of the way quickly - the rest of the app
should be pretty easy after that...
cheers,
John Breen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]