Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37770295
en ru br
ALT Linux repos
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 :: System/Libraries
RPM: libnoch

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <grp.h>
#include <error.h>
#include <errno.h>

int
test_chmod ()
{
const char *filename = "test_chmod";
struct stat st;
int fd;
int rc = 0;

unlink (filename);

fd = open (filename, O_CREAT | O_EXCL, 0600);
if (fd < 0)
error (1, errno, "open");

chmod (filename, 0667);

if (stat (filename, &st))
error (1, errno, "stat");
if ((st.st_mode & (~S_IFMT)) == 0667)
{
puts ("chmod: mode changed");
} else
{
puts ("chmod: mode NOT changed");
rc = 1;
}

fchmod (fd, 0665);

if (stat (filename, &st))
error (1, errno, "stat");
if ((st.st_mode & (~S_IFMT)) == 0665)
{
puts ("fchmod: mode changed");
} else
{
puts ("fchmod: mode NOT changed");
rc = 1;
}

close (fd);

return rc;
}

void
test_chown ()
{
const char *filename = "test_chown";
int fd;
int rc = 0;

unlink (filename);

fd = open (filename, O_CREAT | O_EXCL, 0600);
if (fd < 0)
error (1, errno, "open");

/* test for segfaults only */
rc = chown (filename, -1, -1);
if (rc)
error (1, errno, "chown");

rc = lchown (filename, -1, -1);
if (rc)
error (1, errno, "lchown");

rc = fchown (fd, -1, -1);
if (rc)
error (1, errno, "fchown");
}

int
main ()
{
int rc = 0;

rc = test_chmod ();
test_chown ();
return rc;
}
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin