1 /* Test the k5dcepag routine by setting a pag, and
2 * and execing a shell under this pag.
4 * This allows you to join a PAG which was created
5 * earlier by some other means.
8 * Must be run as root for testing only.
24 typedef struct sigaction handler
;
25 #define handler_init(H,F) (sigemptyset(&(H).sa_mask), \
28 #define handler_swap(S,NEW,OLD) sigaction(S, &NEW, &OLD)
29 #define handler_set(S,OLD) sigaction(S, &OLD, NULL)
31 typedef sigtype (*handler
)();
32 #define handler_init(H,F) ((H) = (F))
33 #define handler_swap(S,NEW,OLD) ((OLD) = signal ((S), (NEW)))
35 #define handler_set(S,OLD) (signal ((S), (OLD)))
41 * We could include the dcedfs/syscall.h which should have these
42 * numbers, but it has extra baggage. So for
43 * simplicity sake now, we define these here.
47 #define AFSCALL_SETPAG 2
48 #define AFSCALL_GETPAG 11
51 #define AFS_SYSCALL 72
54 /* assume HPUX 10 + or is it 50 */
55 #define AFS_SYSCALL 326
58 #define DPAGAIX "dpagaix"
59 /* #define DPAGAIX "/krb5/sbin/dpagaix" */
61 #elif defined(sgi) || defined(_sgi)
62 #define AFS_SYSCALL 206+1000
65 #define AFS_SYSCALL (Unknown_DFS_AFS_SYSCALL)
68 static sigjmp_buf setpag_buf
;
70 static sigtype
mysig()
72 siglongjmp(setpag_buf
, 1);
76 int krb5_dfs_newpag(new_pag
)
83 handler_init (sa1
, mysig
);
84 handler_init (sa2
, mysig
);
85 handler_swap (SIGSYS
, sa1
, osa1
);
86 handler_swap (SIGSEGV
, sa2
, osa2
);
88 if (sigsetjmp(setpag_buf
, 1) == 0) {
90 int (*dpagaix
)(int, int, int, int, int, int);
92 if (dpagaix
= load(DPAGAIX
, 0, 0))
93 pag
= (*dpagaix
)(AFSCALL_SETPAG
, new_pag
, 0, 0, 0, 0);
95 pag
= syscall(AFS_SYSCALL
,AFSCALL_SETPAG
, new_pag
, 0, 0, 0, 0);
97 handler_set (SIGSYS
, osa1
);
98 handler_set (SIGSEGV
, osa2
);
102 fprintf(stderr
,"Setpag failed with a system error\n");
103 /* syscall failed! return 0 */
104 handler_set (SIGSYS
, osa1
);
105 handler_set (SIGSEGV
, osa2
);
118 unsigned int newpag
= 0;
122 while((rv
= getopt(argc
,argv
,"n:")) != -1) {
126 sscanf(optarg
,"%8x",&newpag
);
129 printf("Usage: k5dcepagt -n pag \n");
135 fprintf (stderr
,"calling k5dcepag newpag=%8.8x\n",newpag
);
136 pag
= krb5_dfs_newpag(newpag
);
138 fprintf (stderr
,"PAG returned = %8.8x\n",pag
);
139 if ((pag
!= 0) && (pag
!= -1)) {
141 "FILE:/opt/dcelocal/var/security/creds/dcecred_%8.8x",
143 esetenv("KRB5CCNAME",ccname
,1);
144 execl("/bin/csh", "csh", NULL
);
147 fprintf(stderr
," Not a good pag value\n");