Exemplo n.º 1
0
bool CVSService::setUserPassword(const char *username, const char *password)
{
	// Repository is not initialized, just return false.
	if (!m_isRepoInitialized)
		return false;

	char filename[MAX_PATH + 24];
	FILE *fp;

	// Write user name password to 'passwd' file.
	if ((fp = fopen(strcat(strcpy(filename, m_repoPath), "/CVSROOT/passwd"), "w")) == NULL)
		return false;
	fprintf(fp, "%s:%s:%s\n", username, __crypt(password), getpwuid(getuid())->pw_name);
	fclose(fp);

	// Write user name to 'reader' file.
	if ((fp = fopen(strcat(strcpy(filename, m_repoPath), "/CVSROOT/reader"), "w")) == NULL)
		return false;
	fprintf(fp, "%s\n", username);
	fclose(fp);

	// Write user name to 'writer' file.
	if ((fp = fopen(strcat(strcpy(filename, m_repoPath), "/CVSROOT/writer"), "w")) == NULL)
		return false;
	fprintf(fp, "%s\n", username);
	fclose(fp);

	// Return true.
	return true;
}
Exemplo n.º 2
0
static int modcrypt_decrypt2( INSTANCE * my, int * params )
{
    int r;
    crypt_handle * ch = crypt_create( params[0], ( char * ) params[1] );
    r = __crypt( ch, ( char * ) params[2], ( char * ) params[3], params[4], 0 );
    crypt_destroy( ch );
    return r;
}
Exemplo n.º 3
0
static int __eaxcrypt(uword* nonce, uword* data, size_t datalen, uword* key,
                     int (*__crypt)(const void*, void*, unsigned long, eax_ctx*) )   {
    eax_ctx context;
    int     retval;
    
    retval = eax_init_and_key(key, &context);
    if (retval == 0) {
        retval = __crypt((const void*)nonce, (void*)data, (ulong)datalen, &context);
        retval = retval ? -2 : 4;
    }
    return retval;
}
Exemplo n.º 4
0
void communicate(int sock){
    char buffer[PACKETSIZE];
    int numRead;

    do{
        //read text and key buffer[0-HALFPACKET-1] = text
        //                     buffer[HALFPACKET - PACKETSIZE-1] = key
        numRead = read(sock,buffer,PACKETSIZE);
        if(numRead < 0) {
            fprintf(stderr,"[%d] %s\n",getpid(),"error on socket read");
            if(errno){
               const char* error = strerror(errno);
               fprintf(stderr, "%s\n",error);
            }
        }
        else if(numRead){
            //process text/key send back crypted text
            int numOut = __crypt(buffer,buffer+HALFPACKET);
            write(sock,buffer,numOut);
        }

    }while(numRead);
}
Exemplo n.º 5
0
static int modcrypt_decrypt( INSTANCE * my, int * params )
{
    return ( __crypt( ( crypt_handle * ) params[0], ( char * ) params[1], ( char * ) params[2], params[3], 0 ) );
}