Example #1
0
int cgi_access_manager::cgi_access_write(const CString& container){

#ifndef ANSI

	chmod(container.asString(), _S_IREAD | _S_IWRITE);

#endif
	int hfile2 = v_open(container.asString(), O_WRONLY | O_TRUNC | O_CREAT, S_IRWXU);    

	if (hfile2 == -1) {

		perror("<br>Error writing access.struct:");

		return 0;

	}

    for (int m = 0; m<entry_manager::entries_count();m++) {
		write(hfile2, entry_manager::get_name(m).asString(), entry_manager::get_name(m).StrLength());
		write(hfile2, ",", strlen(","));
		CString PasswdValue(entry_manager::get_value(m).Encrypt());
		write(hfile2, PasswdValue.asString(), PasswdValue.StrLength());
		write(hfile2, "\n", strlen("\n"));
    }
    close(hfile2);
    return 1;
}
Example #2
0
int cgi_access_manager::write_full_access(const CString& Equiv, const CString& Password){
	if (!equiv_file.StrLength()) {
		current_cgi_access_manager = this;
		equiv_file = entry_manager::make_equiv_path("access.struct");
	}

#ifndef ANSI

	chmod(equiv_file.asString(), _S_IREAD | _S_IWRITE);

#endif

	int hfile2 = v_open(equiv_file.asString(), O_WRONLY | O_APPEND | O_CREAT, S_IRWXU);

	if (hfile2 == -1) {

		perror("<br>Error writing access.struct:");

		return 0;

	}
    CString EPassword(Password);    
    write(hfile2, Equiv.asString(), Equiv.StrLength());    
    write(hfile2, ",", strlen(","));

	CString EncryptedPassword(EPassword); EncryptedPassword.Encrypt();
    write(hfile2, EncryptedPassword.asString(), EncryptedPassword.StrLength());
    write(hfile2, "\n", strlen("\n"));  
    close(hfile2);
    return 1;      
}