SUMMARY: C program won't run on DU 4.0B

From: Paul N. Youngblood <youngbp_at_email.uah.edu>
Date: Thu, 12 Jun 1997 17:25:34 -0500 (CDT)

Hello Managers,

This list is terrific as usual! Fast answers to
my problem came from:
 
 Randy M. Hayman <haymanr_at_icefog.sois.alaska.edu>
 Marco Campani <campa_at_ge.INFM.it>

Both said that I should change this line in my program:
   set_auth_parameters();
to this:
   set_auth_parameters(argc, argv);
This solved my problem. Thanks, Randy and Marco!
Now when I compile it on DU 4.0B it runs fine.

Also, very helpful were:
 Pam Woods, Systems Manager <axsymgr_at_UAA.ALASKA.EDU>
 John P. Speno <speno_at_swarthmore.edu>
 Jo Knox <fxjwk_at_aurora.alaska.edu
Thank you all for responding. My original post is below.

Paul Youngblood
University of Alabama in Huntsville

------- Original Post ---------------------------------

Hello Managers,

I run DU 4.0B on one AlphaServer 2100 and DU 3.2d-1 on another.
Both run C2 Security. I have a handy little C program that I
use to set the expiration date on a user's account. (Somebody
on this listserver gave me a copy of it quite a while ago.)

On the 4.0B machine, I can compile it just fine, but when I run
the program I get a core dump:

   # ./expireone someuser
   Memory fault - core dumped

The only way I can get this program to run successfully on the
4.0B machine is to do the actual compiling on the 3.2d-1 machine,
and then copy the resulting binary over to the 4.0B machine:

   # ./expireone someuser
   someuser will expire on Mon Jun 30 01:00:00 1997
 
I've installed the second major patch for 4.0B that Digital
has made available, but not the third. I'll be installing that
third patch within a week or two just to stay current, but I
don't have any reason to suspect that this will fix my problem.
Has anyone got any ideas on what may be wrong? I'll summarize
any help I get. I've included a copy of my small c program
below. Please note that the original program was interactive
and that I changed it. It is crude (the date of expiration is
now hard-coded!) but does what I need.
Thanks for any help you can give me!

Paul Youngblood
University of Alabama in Huntsville
e-mail: youngbloodp_at_uah.edu

------------ cut ---------- cut ----------- cut ----------
/*
    Usage: expireone USERNAME

This program expires one user at a time. It is no longer
interactive, so you can use it in a shell script, within a
loop construct to expire a list of users.

Just hard code the date for expiration in the code below,
recompile, and you are ready to use this program.

To compile: cc expireone.c -o expireone -lsecurity

*/

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <sys/security.h>
#include <prot.h>

void error( why )
char *why;
{
        printf( "Error: %s\n", why );
        exit(1);
}

struct pr_passwd *temp;
struct pr_passwd ent;

main(int argc, char *argv[])
{
        struct tm timp={0,0,0,0,0,0,};
        time_t tp;
        int i,j;
        int month,day,year;
        char instr[200];

        set_auth_parameters(); /* This must be done first! */

        if (argc == 1) error( "Usage: expire <username>\n" );

        temp = getprpwnam(argv[1]);
        if ( temp==NULL ) error( "Can't find user\n" );
        ent=*temp;

               /*printf("Username: %s\n",ent.ufld.fd_name);*/

        /*printf("Date to expire %s? (mm/dd/yy)> ",argv[1]);*/
        /*gets( instr );*/
        /*if( !instr[0] ) exit( 0 );*/
        /*sscanf( instr, "%d/%d/%d", &month, &day, &year );*/
        month = 6;
        day = 30;
        year = 97;
        if (month<1 || month>12) error( "Invalid month.\n" );
        if (day<1 || day>31) error( "Invalid day.\n" );
        if (year<70) error( "Invalid year.\n" );
        month--;
        timp.tm_mon = month;
        timp.tm_mday = day;
        timp.tm_year = year;
        tp=mktime(&timp);
        ent.ufld.fd_expdate=tp;
        ent.uflg.fg_expdate=1;

        printf("%s will expire on %s\n",argv[1],asctime(localtime(&tp)));

        putprpwnam(argv[1],&ent);

}
Received on Fri Jun 13 1997 - 00:34:13 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:36 NZDT