summaryrefslogtreecommitdiffstats
path: root/143/regr/ctestfun.c
blob: 4184a21a2a473d39c9716f7142a7d22fbd3d64eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <malloc.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

int main (int argc,char *argv[]) {
  char *n0 = NULL;
  struct stat *buf1 = NULL;
  int ret = 0;

  n0 = argv[1];
  buf1 = calloc (1, sizeof (*buf1));
  gid_t list[3] = {65533, 65532, 65531};

  creat (n0, 0644);
  chown (n0, 65534, 65533);
  chmod (n0, 06555);

  setgroups (3, &list);
  setuid (65534);

  chown (n0, 65534, 65532);
  ret = stat (n0, buf1);
  if (ret == -1) {
	printf ("stat error, error no = %d",errno);
        exit (EXIT_FAILURE);
  }
  if (buf1->st_gid != 65532)
        exit (EXIT_FAILURE);

  free (buf1);
  
  exit (EXIT_SUCCESS);
}