Skip to content
Snippets Groups Projects
Commit 0c5798e7 authored by Dennis Waldron's avatar Dennis Waldron
Browse files

Removed the newacct command and manpage

parent 1d6581c3
Branches
Tags
No related merge requests found
......@@ -20,7 +20,6 @@ ClientProgramTarget(stager_qry,stager_qry.Osuf,$(DEPLIB),$(LIBS),0755)
ClientProgramTarget(stager_rm,stager_rm.Osuf,$(DEPLIB),$(LIBS),0755)
ClientProgramTarget(stager_setfilegcweight,stager_setFileGCWeight.Osuf,$(DEPLIB),$(LIBS),0755)
ClientProgramTarget(castor,castor.Osuf,$(DEPLIB),$(LIBS),0755)
ClientProgramTarget(newacct,newacct.Osuf,$(DEPLIB),$(LIBS),4755)
ClientProgramTarget(stager_addprivilege,stager_addPrivilege.Osuf,$(DEPLIB),$(LIBS),0755)
ClientProgramTarget(stager_removeprivilege,stager_removePrivilege.Osuf,$(DEPLIB),$(LIBS),0755)
ClientProgramTarget(stager_listprivileges,stager_listPrivileges.Osuf,$(DEPLIB),$(LIBS),0755)
......@@ -32,7 +31,6 @@ EXEMANPAGE(stager_putdone)
EXEMANPAGE(stager_qry)
EXEMANPAGE(stager_rm)
EXEMANPAGE(stager_setfilegcweight)
EXEMANPAGE(newacct)
EXEMANPAGE(stager_addprivilege)
EXEMANPAGE(stager_removeprivilege)
EXEMANPAGE(stager_listprivileges)
/*
* $Id: newacct.c,v 1.9 2008/03/13 10:16:49 waldron Exp $
*/
/*
* Copyright (C) 1990-2000 by CERN/IT/PDP/DM
* All rights reserved
*/
/* newacct Command to change current account */
#include <stdlib.h>
#include <stdio.h>
#if !defined(apollo) && !defined(_WIN32)
#include <unistd.h>
#endif
#include <string.h>
#if defined(_WIN32)
#include <stdlib.h>
#else
#include <sys/param.h>
#endif
#include <sys/types.h>
#include <grp.h>
#include <pwd.h>
extern char * getacctent() ;
extern struct group * getgrnam() ;
static void setacct(pwd,account,shell_opt)
struct passwd * pwd ;
char * account ;
char * shell_opt ;
{
extern int putenv() ;
extern char * getenv() ;
static char strenv[16] ;
#if defined(_WIN32)
char shell[_MAX_PATH] ;
#else
char shell[MAXPATHLEN] ;
#endif
char * cp ;
struct group * g ;
(void) sprintf(strenv,"ACCOUNT=%s",account) ;
if ( putenv(strenv) ) {
(void) fprintf(stderr,"newacct: insufficient space to expand the environment\n") ;
exit(1) ;
}
#if !defined(_WIN32)
/* change group in case of multiple accounts */
if ( (cp= strchr(account,'$')) != NULL ) {
if ( (g= getgrnam(++cp)) == NULL ) { ;
(void) fprintf(stderr,"newacct: invalid group %s\n",cp) ;
exit(1) ;
}
setgid(g->gr_gid) ;
#if (defined(_AIX) && defined(_IBMR2)) || defined(sgi)
setgroups(1,&g->gr_gid) ;
#endif
#if hpux
setresuid(-1,pwd->pw_uid,-1) ;
#else
seteuid(pwd->pw_uid) ;
#endif
}
#endif
if (shell_opt)
cp= shell_opt ;
else if ( ( cp= getenv("SHELL")) == NULL )
cp= pwd->pw_shell ;
if ( strlen(cp) >= sizeof(shell) ) {
(void) fprintf(stderr,"newacct: invalid shell name %s\n",cp) ;
exit(1) ;
}
if ( *cp == 0)
cp= "/bin/sh" ;
(void) strcpy(shell,cp) ;
if ( (cp= strrchr(cp,'/')) != NULL )
cp ++ ;
else
cp= shell;
execl(shell,cp,NULL) ;
(void) fprintf(stderr,"newacct: %s not found\n",shell) ;
exit(1) ;
}
int main(argc,argv)
int argc ;
char ** argv ;
{
char buffer[80] ;
int c ;
char * cp ;
struct passwd * pwd ;
char * shell= NULL ;
char * account ;
extern char *optarg;
extern int optind;
/*
* Checking arguments
* Setting account.
*/
while ((c = getopt (argc, argv, "s:")) != EOF) {
switch (c) {
case 's':
shell= optarg;
break;
case '?':
exit(1);
default:
break;
}
}
if ( (argc-optind) > 1 ) {
(void) fprintf(stderr,"usage is: newacct [accountid] \n") ;
exit(1) ;
}
if ( optind < argc && (int)strlen(argv[optind]) > 6 ) {
(void) fprintf(stderr,"newacct: invalid account id specified\n") ;
exit(1) ;
}
account= ( optind == argc ) ? NULL : argv[optind] ;
/*
* Getting password entry.
*/
if ( (pwd= getpwuid(getuid())) == NULL ) {
(void) fprintf(stderr,"newacct: who are you ?\n") ;
exit(1) ;
}
if ( (cp= getacctent(pwd,account,buffer,sizeof(buffer))) == NULL ) {
if ( account )
(void) fprintf(stderr,"newacct: invalid account id specified\n") ;
else
(void) fprintf(stderr,"newacct: no entry for %s in account file\n",
pwd->pw_name) ;
exit(1) ;
}
/*
* Parsing the entry
*/
cp= strtok(cp,":") ; /* login name */
cp= strtok((char *)NULL,":") ; /* account id */
/*
* Setting the new account.
*/
setacct(pwd,cp,shell) ;
/* NOTREACHED */
exit(0);
}
.\" @(#)$RCSfile: newacct.man,v $ $Revision: 1.3 $ $Date: 2001/09/26 09:13:38 $ CERN IT-PDP/DC Antoine Trannoy
.\" Copyright (C) 1990-2000 by CERN/IT/PDP/DC
.\" All rights reserved
.\"
.TH NEWACCT 1 "$Date: 2001/09/26 09:13:38 $" CASTOR "User Commands"
.SH NAME
newacct \- log in to a new account
.SH SYNOPSIS
.B /usr/local/bin/newacct
[
.BI -s " shellname"
] [
.I account
]
.SH DESCRIPTION
.B newacct
changes a user's account identification. Only the account-ID and possibly the
group id are changed. The user remains
logged in and the current directory is unchanged. If
.B newacct
terminates successfully, the user is given a new shell, replacing the current shell.
The new shell is selected in the following way:
a shellname can be specified with the option -s, if not and the environment
variable
.B SHELL
is set, its value is used; if not set, the shell field in the password file is
used; if empty, the Bourne shell is used.
Exported variables retain their values after invoking
.BR newacct ;
however, all unexported variables are either reset to their default value or set to null.
.LP
With no argument,
.B newacct
changes the account identification back to the default account for the user. If an account-ID
is specified,
.B newacct
checks that it is a valid one.
.LP
.B newacct
sets the environment variable
.SM ACCOUNT
with the new account identifier.
.SH EXAMPLES
.LP
1) Bourne Shell
.nf
newacct -s /bin/sh 'uuu$gg' <<EOC
echo "\\n secondary account [\\${ACCOUNT}]"
id
EOC
.fi
.LP
2) C Shell
.nf
newacct -s /bin/csh 'uuu$gg' <<EOC
echo ""
echo " secondary account [\\${ACCOUNT}]"
id
EOC
.fi
.LP
3) Perl
.nf
open (NEWACCT, "| newacct -s /usr/local/bin/perl 'uuu$gg'") || exit (1);
print NEWACCT <<EOC;
print "\\n secondary account [\\$ENV{ACCOUNT}]\\n", `id`;
EOC
close (NEWACCT);
.fi
.SH FILES
.B /etc/account
.SH SEE ALSO
.BR account (4),
.BR getacct (3)
.SH AUTHOR
\fBCASTOR\fP Team <castor.support@cern.ch>
......@@ -9,4 +9,3 @@
%attr(0755,root,root) usr/bin/stager_removeprivilege
%attr(0755,root,root) usr/bin/stager_listprivileges
%attr(0755,root,root) usr/bin/castor
%attr(4755,root,root) usr/bin/newacct
......@@ -5,7 +5,6 @@ debian/castor/usr/share/man/man1/stager_putdone.1castor
debian/castor/usr/share/man/man1/stager_qry.1castor
debian/castor/usr/share/man/man1/stager_rm.1castor
debian/castor/usr/share/man/man1/stager_setfilegcweight.1castor
debian/castor/usr/share/man/man1/newacct.1castor
debian/castor/usr/share/man/man1/stager_addprivilege.1castor
debian/castor/usr/share/man/man1/stager_removeprivilege.1castor
debian/castor/usr/share/man/man1/stager_listprivileges.1castor
\ No newline at end of file
debian/castor/usr/share/man/man1/stager_listprivileges.1castor
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment