Hi, Subrata

You wrote:
> 2) setgid16
> Comments: We have setgid at *testcases/kernel/syscalls/setgid. *You may need
> to include/port setgid16 on similar lines to sendfile64 and fadvise64.

I've tried this task.

Please put compat_16.h to testcases/kernel/syscalls/setgid.
And apply following patch before rebuilding tests.

In addition I removed one getgid() invocation in
testcases/kernel/syscalls/setgid/setgid02.c because the returned value
is not used anywhere in the program.

Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]>


Index: runtest/syscalls
===================================================================
RCS file: /cvsroot/ltp/ltp/runtest/syscalls,v
retrieving revision 1.202
diff -c -r1.202 syscalls
*** runtest/syscalls    26 Jul 2008 04:15:36 -0000      1.202
--- runtest/syscalls    31 Jul 2008 11:26:37 -0000
***************
*** 745,752 ****
--- 745,755 ----
  setfsuid03 setfsuid03
  
  setgid01 setgid01
+ setgid01_16 setgid01_16
  setgid02 setgid02
+ setgid02_16 setgid02_16
  setgid03 setgid03
+ setgid03_16 setgid03_16
  
  setegid01 setegid01
  
Index: testcases/kernel/syscalls/setgid/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgid/Makefile,v
retrieving revision 1.7
diff -c -r1.7 Makefile
*** testcases/kernel/syscalls/setgid/Makefile   21 Aug 2006 06:58:45 -0000      
1.7
--- testcases/kernel/syscalls/setgid/Makefile   31 Jul 2008 11:27:23 -0000
***************
*** 19,26 ****
  CFLAGS += -I../../../../include -Wall
  LDLIBS += -L../../../../lib -lltp
  
! SRCS    = $(wildcard *.c)
! TARGETS = $(patsubst %.c,%,$(SRCS))
  
  all: $(TARGETS)
  
--- 19,33 ----
  CFLAGS += -I../../../../include -Wall
  LDLIBS += -L../../../../lib -lltp
  
! SRCS    = $(wildcard *[0-9][0-9].c)
! TARGETS = $(patsubst %.c,%,$(SRCS)) $(patsubst %.c,%_16,$(SRCS))
! 
! 
! %.c: compat_16.h
! %_16.c: %.c 
!       echo "#define USE_COMPAT16_SYSCALL 1" > $@
!       cat $< >> $@
! 
  
  all: $(TARGETS)
  
Index: testcases/kernel/syscalls/setgid/setgid01.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgid/setgid01.c,v
retrieving revision 1.2
diff -c -r1.2 setgid01.c
*** testcases/kernel/syscalls/setgid/setgid01.c 26 May 2006 06:26:40 -0000      
1.2
--- testcases/kernel/syscalls/setgid/setgid01.c 31 Jul 2008 11:27:23 -0000
***************
*** 118,131 ****
  void setup();
  void cleanup();
  
! 
  
  char *TCID="setgid01";                /* Test program identifier.    */
  int TST_TOTAL=1;              /* Total number of test cases. */
  extern int Tst_count;         /* Test Case counter for tst_* routines */
  
  int exp_enos[]={0, 0};
! int gid;
  
  int
  main(int ac, char **av)
--- 118,131 ----
  void setup();
  void cleanup();
  
! #include "compat_16.h"
  
  char *TCID="setgid01";                /* Test program identifier.    */
  int TST_TOTAL=1;              /* Total number of test cases. */
  extern int Tst_count;         /* Test Case counter for tst_* routines */
  
  int exp_enos[]={0, 0};
! GID_T gid;
  
  int
  main(int ac, char **av)
***************
*** 158,164 ****
        /* 
         * Call setgid(2) 
         */
!       TEST(setgid(gid));
        
        /* check return code */
        if ( TEST_RETURN == -1 ) {
--- 158,164 ----
        /* 
         * Call setgid(2) 
         */
!       TEST(SETGID(gid));
        
        /* check return code */
        if ( TEST_RETURN == -1 ) {
***************
*** 196,203 ****
  
      /* Pause if that option was specified */
      TEST_PAUSE;
! 
!     gid = getgid();
  }     /* End setup() */
  
  
--- 196,203 ----
  
      /* Pause if that option was specified */
      TEST_PAUSE;
!     
!     gid = GETGID();
  }     /* End setup() */
  
  
Index: testcases/kernel/syscalls/setgid/setgid02.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgid/setgid02.c,v
retrieving revision 1.4
diff -c -r1.4 setgid02.c
*** testcases/kernel/syscalls/setgid/setgid02.c 27 Mar 2003 20:06:03 -0000      
1.4
--- testcases/kernel/syscalls/setgid/setgid02.c 31 Jul 2008 11:27:23 -0000
***************
*** 61,71 ****
  void setup(void);
  void cleanup(void);
  
  int exp_enos[] = {EPERM, 0};
  
  int main(int ac, char **av)
  {
-       int gid;
        struct passwd *getpwnam(), *rootpwent;
  
        int lc;                         /* loop counter */
--- 61,72 ----
  void setup(void);
  void cleanup(void);
  
+ #include "compat_16.h"
+ 
  int exp_enos[] = {EPERM, 0};
  
  int main(int ac, char **av)
  {
        struct passwd *getpwnam(), *rootpwent;
  
        int lc;                         /* loop counter */
***************
*** 86,99 ****
                /* reset Tst_count in case we are looping */
                Tst_count = 0;
  
-               gid = getgid();
  
                if ((rootpwent = getpwnam(root)) == NULL) {
                        tst_brkm(TBROK, cleanup, "getpwnam failed for user id "
                                 "%s", root);
                }
  
!               TEST(setgid(rootpwent->pw_gid));
  
                if (TEST_RETURN != -1) {
                        tst_resm(TFAIL, "call succeeded unexpectedly");
--- 87,106 ----
                /* reset Tst_count in case we are looping */
                Tst_count = 0;
  
  
                if ((rootpwent = getpwnam(root)) == NULL) {
                        tst_brkm(TBROK, cleanup, "getpwnam failed for user id "
                                 "%s", root);
                }
  
!               if (!COMPAT_SIZE_CHECK(rootpwent->pw_gid)) {
!                tst_brkm(TBROK, 
!                         cleanup, 
!                         "gid for `%s' is too large for testing setgid16", 
!                         root);
!               }
!               
!               TEST(SETGID(rootpwent->pw_gid));
  
                if (TEST_RETURN != -1) {
                        tst_resm(TFAIL, "call succeeded unexpectedly");
***************
*** 125,131 ****
          if (geteuid() != 0) {
                  tst_brkm(TBROK, tst_exit, "Test must be run as root");
          }
!          ltpuser = getpwnam(nobody_uid);
         if (setgid(ltpuser->pw_gid) == -1) {
                  tst_resm(TINFO, "setgid failed to "
                           "to set the effective gid to %d",
--- 132,146 ----
          if (geteuid() != 0) {
                  tst_brkm(TBROK, tst_exit, "Test must be run as root");
          }
!       ltpuser = getpwnam(nobody_uid);
! 
!        if (!COMPAT_SIZE_CHECK(ltpuser->pw_gid)) {
!                tst_brkm(TBROK, 
!                         cleanup, 
!                         "gid for `%s' is too large for testing setgid16", 
!                         nobody_gid);
!        }
! 
         if (setgid(ltpuser->pw_gid) == -1) {
                  tst_resm(TINFO, "setgid failed to "
                           "to set the effective gid to %d",
Index: testcases/kernel/syscalls/setgid/setgid03.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgid/setgid03.c,v
retrieving revision 1.3
diff -c -r1.3 setgid03.c
*** testcases/kernel/syscalls/setgid/setgid03.c 27 Mar 2003 20:06:03 -0000      
1.3
--- testcases/kernel/syscalls/setgid/setgid03.c 31 Jul 2008 11:27:23 -0000
***************
*** 59,64 ****
--- 59,66 ----
  void setup(void);
  void cleanup(void);
  
+ #include "compat_16.h"
+ 
  int main(int ac, char **av)
  {
        int lc;                         /* loop counter */
***************
*** 135,140 ****
--- 137,151 ----
                tst_brkm(TBROK, cleanup, "getpwnam failed for user "
                         "id %s", ltpuser1);
        }
+ 
+       if (!(COMPAT_SIZE_CHECK(rootpwent->pw_gid))) {
+               tst_brkm(TBROK, 
+                        cleanup, 
+                        "gid for `%s' is too large for testing setgid16", 
+                        root);
+       }
+         
+       
  }
  
  /*
/*
 *
 *   Copyright (c) Red Hat Inc., 2008
 *
 *   This program is free software;  you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 *   the GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program;  if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

/* Author: Masatake YAMATO <[EMAIL PROTECTED]> */

#ifndef __SETGID_COMPAT_16_H__
#define __SETGID_COMPAT_16_H__


#include <asm/posix_types.h>
#include "linux_syscall_numbers.h"


#ifdef USE_COMPAT16_SYSCALL
typedef __kernel_old_gid_t GID_T;
int 
COMPAT_SIZE_CHECK(gid_t gid)
{
        /* See high2lowgid in linux/highuid.h
           Return 0 if gid is too large to store
           it to __kernel_old_gid_t. */
        return ((gid) & ~0xFFFF)? 0: 1;
}
int 
SETGID(GID_T gid)
{
        return syscall(__NR_setgid, gid);
}
GID_T
GETGID(void)
{
        gid_t gid;

        gid = getgid();
        if (!COMPAT_SIZE_CHECK(gid))
          tst_brkm(TBROK, 
                   cleanup, 
                   "gid for the current process is too large for testing 
setgid16");

        return (GID_T)gid;
}
#else
typedef gid_t GID_T;
int 
COMPAT_SIZE_CHECK(gid_t gid)
{
        return 1;
}
int 
SETGID(GID_T gid)
{
        return setgid(gid);
}
GID_T
GETGID(void)
{
        return getgid();
}
#endif

#endif /* __SETGID_COMPAT_16_H__ */
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to