Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37858729
en ru br
ALT Linux repositórios
S:0.4.1-alt1
5.0: 0.4-alt1
4.1: 0.4-alt1
4.0: 0.4-alt1
3.0: 0.4-alt1

Group :: Sistema/Bibliotecas
RPM: libnoch

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

#define _GNU_SOURCE

#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <error.h>
#include <errno.h>
#include <dlfcn.h>

#include "vers.h"

static void *
get_func (const char *symbol, const char *version)
{
void *addr;

addr = dlvsym (RTLD_NEXT, symbol, version);
#ifdef DEBUG
fprintf (stderr, "dlvsym (RTLD_NEXT, %s, %s) = %p\n",
symbol, version, addr);
#endif
if (!addr)
error (1, errno, "dlvsym: %s@@%s", symbol, version);
return addr;
}

typedef int (*chown_fptr) (const char *, uid_t, gid_t);

int
chown (const char *path, uid_t owner, gid_t group)
{
if (getuid ())
{
static chown_fptr func = 0;

if (!func)
func = get_func ("chown", chown_vers);
return func (path, owner, group);
}
return 0;
}

typedef int (*lchown_fptr) (const char *, uid_t, gid_t);

int
lchown (const char *path, uid_t owner, gid_t group)
{
if (getuid ())
{
static lchown_fptr func = 0;

if (!func)
func = get_func ("lchown", lchown_vers);
return func (path, owner, group);
}
return 0;
}

typedef int (*fchown_fptr) (int, uid_t, gid_t);

int
fchown (int fd, uid_t owner, gid_t group)
{
if (getuid ())
{
static fchown_fptr func = 0;

if (!func)
func = get_func ("fchown", fchown_vers);
return func (fd, owner, group);
}
return 0;
}

typedef int (*chmod_fptr) (const char *, mode_t);

int
chmod (const char *path, mode_t mode)
{
if (getuid ())
{
static chmod_fptr func = 0;

if (!func)
func = get_func ("chmod", chmod_vers);
return func (path, mode);
}
return 0;
}

typedef int (*fchmod_fptr) (int, mode_t);

int
fchmod (int fildes, mode_t mode)
{
if (getuid ())
{
static fchmod_fptr func = 0;

if (!func)
func = get_func ("fchmod", chmod_vers);
return func (fildes, mode);
}
return 0;
}
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009