Diff for /libaitcfg/inc/aitpwd.h between versions 1.1.2.1 and 1.1.2.5

version 1.1.2.1, 2012/09/18 08:17:59 version 1.1.2.5, 2012/09/18 15:50:59
Line 50  SUCH DAMAGE. Line 50  SUCH DAMAGE.
 #include <time.h>  #include <time.h>
   
   
   #define PWD_CRIT_NAME   0
   #define PWD_CRIT_UID    1
   #define PWD_CRIT_GID    2
   
   
 struct tagAcctDB {  struct tagAcctDB {
         unsigned short  db_ver;          unsigned short  db_ver;
         unsigned char   db_lock;          unsigned char   db_lock;
Line 71  typedef int (*cb_acct_f)(void * /*current db_record*/, Line 76  typedef int (*cb_acct_f)(void * /*current db_record*/,
   
   
 struct tagUser {  struct tagUser {
           int                     usr_fields;
   
         ait_val_t               usr_name;          ait_val_t               usr_name;
         ait_val_t               usr_pass;          ait_val_t               usr_pass;
         ait_val_t               usr_uid;          ait_val_t               usr_uid;
Line 82  struct tagUser { Line 89  struct tagUser {
         ait_val_t               usr_home;          ait_val_t               usr_home;
         ait_val_t               usr_shell;          ait_val_t               usr_shell;
   
        SLIST_ENTRY(tagCfg)       usr_next;        SLIST_ENTRY(tagUser)       usr_next;
        RB_ENTRY(tagCfg)       usr_node;        RB_ENTRY(tagUser)       usr_node;
 };  };
   typedef struct tagPWD {
           pthread_mutex_t         pwd_mtx;
   
typedef struct tagUser * passwd_t;        struct tagUser          *slh_first;
         struct tagUser          *rbh_root;
 } pwd_root_t;
 #define PWD_LOCK(x)     pthread_mutex_lock(&(x)->pwd_mtx)
 #define PWD_UNLOCK(x)   pthread_mutex_unlock(&(x)->pwd_mtx)
   
   #define PWD_ISEMPTY(x)  RB_EMPTY((x))
   
 typedef enum { ALL = -1,   typedef enum { ALL = -1, 
         Username,           Username, 
         Password,           Password, 
Line 102  typedef enum { ALL = -1,  Line 117  typedef enum { ALL = -1, 
 } passwd_attr_t;  } passwd_attr_t;
   
   
 #if 0  
 /*  /*
 * CreatePasswd() Create secrets from memory * cfgInitPasswd() - Init password root
 * @csPasswdName = New filename for secrets *
 * @ppwd = Users array element * @pwd = Password root
 * return: 0 ok; -1 error:: can`t save new file * return: -1 error or 0 ok
*/ */
int CreatePasswd(const char *csPasswdName, passwd_t * __restrict ppwd);int cfgInitPasswd(pwd_root_t * __restrict pwd);
 /*  /*
 * LoadPasswd() Load secrets from file * cfgLoadPasswd() - Load passwords from file
 * @csPasswdName = Filename of secrets *
 * @ppwd = Users array element * @pwdName = Passwords filename
 * return: 0 ok; -1 error:: can`t load file * @pwd = Password root
*/ * return: -1 error or 0 ok
int LoadPasswd(const char *csPasswdName, passwd_t * __restrict ppwd); */
 int cfgLoadPasswd(const char *pwdName, pwd_root_t * __restrict pwd);
 /*  /*
 * UnloadPasswd() Unload secrets from memory and free resources * cfgClearPasswd() - Clear passwords and free resources
 * @ppwd = Users array element *
*/ * @cfg = Password root
void UnloadPasswd(passwd_t * __restrict ppwd); * return: none
  */
 void cfgClearPasswd(pwd_root_t * __restrict pwd);
 /*
  * cfgUnloadPasswd() - Unload passwords from memory and destroy resources
  *
  * @pwd = Password root
  * return: none
  */
 void cfgUnloadPasswd(pwd_root_t * __restrict pwd);
 /*
  * cfgCreatePasswd() - Create password file from memory
  *
  * @pwdName = New password filename
  * @pwd = Password root
  * return: -1 error or 0 ok
  */
 int cfgCreatePasswd(const char *pwdName, pwd_root_t * __restrict pwd);
   
   
 // pwd_GetErrno() Get error code of last operation  
 inline int pwd_GetErrno();  
 // pwd_GetError() Get error text of last operation  
 inline const char *pwd_GetError();  
 // pwd_Delimiter() Operate with file delimiter, if delim == 0 only get current  
 inline unsigned char pwd_GetDelim(unsigned char delim);  
   
   
 /*  /*
 * ReadPasswd() Read from file and add new item to user array * cfgReadPasswd() - Read file and add new item at password root
 * @f = file resource *
 * @ppwd = User array * @f = File resource
 * return: 0 ok; -1 error:: can`t allocate memory * @pwd = Password root
*/ * return: -1 error or 0 ok
int ReadPasswd(FILE *f, passwd_t * __restrict ppwd); */
 int cfgReadPasswd(FILE *f, pwd_root_t * __restrict pwd);
 /*  /*
 * WritePasswd() Write to file from items in array * cfgWritePasswd() - Write passwords from memory
 * @f = file resource *
 * @ppwd = User array * @f = File handle
 * return: 0 ok; -1 error:: can`t write to file * @pwd = Password root
*/ * return: -1 error or 0 ok
int WritePasswd(FILE *f, passwd_t * __restrict ppwd); */
 int cfgWritePasswd(FILE *f, pwd_root_t * __restrict pwd);
 /*
  * cfgConcatPasswd() - Concat two password roots into one
  *
  * @pwd = Password root
  * @add_pwd = Concated password root will be destroy after merge
  * return: -1 error or 0 ok
  */
 int cfgConcatPasswd(pwd_root_t * __restrict pwd, pwd_root_t * __restrict add_pwd);
   
   
 /*  /*
 * pwdCleanStr() Free strings in passwd_t value * cfg_findPasswdBy() - Find user by criteria position in list
 * @pwd = User object *
 * return: none * @pwd = Password root
*/ * @criteria = Search criteria [PWD_CRIT_NAME|PWD_CRIT_UID|PWD_CRIT_GID]
inline void pwdCleanStr(passwd_t __restrict pwd); * @arg1 = Username | UID | GID
  * return: NULL not found item or error and !=NULL found item
  */
 struct tagUser *cfg_findPasswdBy(pwd_root_t * __restrict pwd, int criteria, ...);
 /*
  * cfg_unsetPasswd() - Unset item from passwords and free resources
  *
  * @pwd = Password root
  * @criteria = Search criteria [PWD_CRIT_NAME|PWD_CRIT_UID]
  * @arg1 = Username | UID
  * return: 0 item not found, -1 error or 1 removed item
  */
 int cfg_unsetPasswd(pwd_root_t * __restrict pwd, int criteria, ...);
 
 #if 0
 /*  /*
  * pwdFreeValue() Free passwd_t value   * pwdFreeValue() Free passwd_t value
  * @ppwd = User object   * @ppwd = User object

Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>