🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #16196

Re: Permisos de ficheros desde C.

#16196
From: batsman
Date: Mon, 01 May 2000 00:00
71 lines
3055 bytes
-----BEGIN PGP SIGNED MESSAGE-----


  >> El Sun, 30 Apr 2000 15:55:42 +0200, el siguiente flujo de bytes sali�
  >> del ordenador de Santiago Romero hacia es.comp.os.linux.programacion:

>
> Enas... supongo que ser� una pregunta estupidilla, pero...
> �Como puedo chequear los permisos de un fichero (y concretamente
> ver si tiene permisos 0600) y cambiarlos (a 0600) desde mi
> programa en C?

Um, veamos... 
Para verificar los permisos, stat (2):


STAT(2)             Linux Programmer's Manual             STAT(2)

NAME
       stat, fstat, lstat - get file status

       SYNOPSIS
       #include <sys/stat.h>
       #include <unistd.h>

       int stat(const char *file_name, struct stat *buf);
       int fstat(int filedes, struct stat *buf);
       int lstat(const char *file_name, struct stat *buf);
					  

En cuanto a lo de cambiar los permisos, a mano se hace con chmod (1), 
as� que probemos con chmod (2):

man 2 chmod

CHMOD(2)            Linux Programmer's Manual            CHMOD(2)

NAME
       chmod, fchmod - change permissions of a file

       SYNOPSIS
       #include <sys/types.h>
       #include <sys/stat.h>

       int chmod(const char *path, mode_t mode);
       int fchmod(int fildes, mode_t mode);
				   
M�s sencillo imposible (en especial el chmod :-)

- -- 
              _           _                             
             | |__   __ _| |_ ___ _ __ ___   __ _ _ __  
             | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
             | |_) | (_| | |_\__ \ | | | | | (_| | | | |
             |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|

             Real email: batsman dot geo at yahoo dot com

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: noconv
Comment: Public key via email: send mail with Subject: [PGPKEY]

iQEVAwUBOQ088b0Y27yr0iefAQG1YAf/cc4zfzncSAgLes3msS19RPijddWtvBSH
RlrH68JsDOcYFNzm6E15hLej5343tv2Nco7dN6PrsDeJs0BZOTInvobzbE4lKufO
WFxGkLB1R/jOZlGdprb4UBesj4EVpoo4kdTzo3/znPkZj1YyFW45Mnz9nvN+FXU3
CN39HZLNbCS46ZF8iOaKfg0RjuQjKPztFjX02BmGnc5p24Pj962Jjvp44f8shM+r
/tpd2NkboAyT+NnbS44Uevr0XzfBxtjp2LNXo3H4cdQIZs3d/BciwOoH9fp7GKpu
1v6tJJXcUzCuMFNOK39U5bkfGweQ4z9j6+Vi6hvVhaLVqdNl2tmsVg==
=eAAM
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <mdeje8.s8.ln@simpsons4ever>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <slrn8goequ.kk.nop@compiler.linux.es>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f86c8,cdb85cf650eaeb0e
X-Google-Attributes: gidf86c8,public
From: batsman@simpsons.for.ever (batsman)
Subject: Re: Permisos de ficheros desde C.
Date: 2000/05/01
Message-ID: <mdeje8.s8.ln@simpsons4ever>
X-Deja-AN: 617754103
Content-Transfer-Encoding: 8bit
References: <slrn8goequ.kk.nop@compiler.linux.es>
Content-Type: text/plain; charset=iso-8859-1
X-Complaints-To: abuse@news.wanadoo.es
X-Trace: m2newsread.uni2.es 957162777 62.36.7.95 (Mon, 01 May 2000 08:32:57 MET DST)
Organization: Wanadoo Usenet News - Visita http://www.wanadoo.es/
Mime-Version: 1.0
User-Agent: slrn/0.9.5.3 (UNIX)
Reply-To: see_signature-mira_firma
NNTP-Posting-Date: Mon, 01 May 2000 08:32:57 MET DST
Newsgroups: es.comp.os.linux.programacion