Cyrus and DU C2 Security

From: Jerome M Berkman <jerry_at_uclink.berkeley.edu>
Date: Wed, 10 Jun 1998 12:56:52 -0700 (PDT)

The Cyrus distribution of pwcheck_getpwnam.c does not work with
Digitail UNIX C2 security/shadow password files.
Here is a version that does.

        - Jerry


/* pwcheck_getpwnam.c -- check passwords using getpwname()
 *
 * Copyright 1996, Carnegie Mellon University. All Rights Reserved.
 *
 * This software is made available for academic and research
 * purposes only. No commercial license is hereby granted.
 * Copying and other reproduction is authorized only for research,
 * education, and other non-commercial purposes. No warranties,
 * either expressed or implied, are made regarding the operation,
 * use, or results of the software. Such a release does not permit
 * use of the code for commercial purposes or benefits by anyone
 * without specific, additional permission by the owner of the code.
 *
 */

#include <stdio.h>
#include <sys/types.h>
#include <sys/security.h>
/* need Digital UNIX version of prot.h, not CMU version which isn't
   relevant here. */
#include "/usr/include/prot.h"

struct pr_passwd *getprpwnam();
encrypt_pw_osf();


/*
 * CMU version out of date - rewritten by Jerry Berkman, UCB,
 * June 1, 1998
 */

char *pwcheck(char *userid, char *password)
{
    struct pr_passwd *pr_pwd;
    char enc_pw_osf[30];

    pr_pwd = getprpwnam(userid);
    if ( pr_pwd == NULL ) {
        return "Userid not found";
    }
    
    encrypt_pw_osf( password, enc_pw_osf, pr_pwd->ufld.fd_encrypt );
    if (strcmp(pr_pwd->ufld.fd_encrypt, enc_pw_osf ) != 0) {
        return "Incorrect password";
    } else {
        return "OK";
    }
}

encrypt_pw_osf( raw_pw, enc_pw_osf, salt )
char *raw_pw;
char *enc_pw_osf;
char *salt;
{
        char *crypt();
        char *ptr;
        char temp_raw[9];
        char temp_encr[14];

        /*
         * crypt password using OSF encryption scheme for C-2 security
         */

        /* encrypt first 8 characters */
        strcpy( enc_pw_osf, crypt( raw_pw, salt ) );
        if( strlen( raw_pw ) > 8 ) {
                /* next 8 characters */
                ptr = crypt( raw_pw+8, enc_pw_osf+2 );
                strcat( enc_pw_osf, ptr + 2 );
        }
}
Received on Wed Jun 10 1998 - 21:59:10 NZST

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