tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* C program won't run on DU 4.0B
@ 1997-06-11 21:38 Paul N. Youngblood
  0 siblings, 0 replies; only message in thread
From: Paul N. Youngblood @ 1997-06-11 21:38 UTC (permalink / raw)
  To: tru64-unix-managers

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@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);

}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-06-11 21:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-06-11 21:38 C program won't run on DU 4.0B Paul N. Youngblood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox