chsh program

From: Ellen Davis <daviser_at_email.uc.edu>
Date: Thu, 21 Jan 1999 14:12:06 -0500

Hello managers,

I have a need to be able to change a user's shell via the web. I am
running DU4.0D with enhanced security. I have written a small C program
(based on a program from another posting). I have never used the sia
routines before. This program seems to work ok. Does anyone see any
problesm which may arise beside the normal checks (account exists, do not
change root accounts).


#include <sia.h>
#include <siad.h>

int my_collect(int timeout, int rendition, unsigned char* title, int
num_prompts, prompt_t *prompts)
{

unsigned char ftpshell[] = "/usr/local/ftpshell";

/* IF the user's shell is /usr/local/profile, then change it to
/usr/local/ftpshell
 * Else return error
 */

   if (strncmp(prompts[0].prompt, "Old shell: /usr/local/profile\nNew
shell: ",39)
        == 0) {
        printf("Changing shell ...\n");
        strncpy(prompts[0].result,ftpshell);
        return SIACOLSUCCESS;
        }
   else return SIACOLABORT;
}
int
main(int argc, char** argv)
{

        /* If no user name is specified, then the sia routines change the
         * current user's info.
         */
        char* user = 0;
        char* progname;
        int i,res;

        /* strip off leading path to work out who we are */
        /*progname = strrchr(argv[0], '/'); */
        progname = argv[0] = "chsh";
        user = argv[1];

        /*sia_chk_invoker(); */

        res = sia_chg_shell(my_collect, user, argc, argv);
        if (res == SIASUCCESS) printf("Shell was changed.\n");
        else printf("Shell was not changed.\n");
        return res;
}

 Ellen Davis
 Ellen.Davis_at_uc.edu
Received on Thu Jan 21 1999 - 19:13:07 NZDT

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