Creating a new PAG from within a program is really simple.  Below is a
sample bit of code that shows how to use the "setpag()" call to do the
job.  You can tell what PAG you're in with the Unix "groups" command.
The program calls that command before and after to demonstrate that
a new PAG was really created.

Joe Jackson,
AFS Product Support,
Transarc Corp.
___________________________________________________________________________

Here's a sample run:

% groups                        # See what PAG I was assigned at login
33536 32520 transarc

% ./t                           # Get a new PAG
Getting initial list of groups
33536 32520 transarc
Calling setpag
Getting new list of groups
33536 32521 transarc

% ./t                           # Run it again to get another new PAG
Getting initial list of groups
33536 32520 transarc
Calling setpag
Getting new list of groups
33536 32522 transarc
___________________________________________________________________________

Here's the code and compilation instructions:

/* 
   setpag-test.c
   Joseph Jackson
   17-Sep-1993

   Simple example program which calls "setpag".
   The Unix "groups" command is used as a cheap way of showing PAG membership.

   Compile with this command:
   cc setpag-test.c -L/usr/afsws/lib -L/usr/afsws/lib/afs -lsys -lrx -llwp
*/

#include <stdio.h>

int main ()
{
   printf("Getting initial list of groups\n");
   system("groups");

   printf("Calling setpag\n");
   setpag();

   printf("Getting new list of groups\n");
   system("groups");

   return 0;
}

Reply via email to