Back to index

openldap  2.4.31
Defines | Functions | Variables
shadow.c File Reference
#include "nssov.h"

Go to the source code of this file.

Defines

#define UID_KEY   0
#define PWD_KEY   1
#define CHG_KEY   2
#define MIN_KEY   3
#define MAX_KEY   4
#define WRN_KEY   5
#define INA_KEY   6
#define EXP_KEY   7
#define FLG_KEY   8
#define UF_DONT_EXPIRE_PASSWD   0x10000
#define GET_OPTIONAL_LONG(var, key)
#define GET_OPTIONAL_DATE(var, key)

Functions

static long to_date (struct berval *date, AttributeDescription *attr)
 NSSOV_CBPRIV (shadow, char buf[256];struct berval name;)
static int write_shadow (nssov_shadow_cbp *cbp, Entry *entry)

Variables

static struct berval = BER_BVC("(objectClass=shadowAccount)")
static int default_nums []

Define Documentation

#define CHG_KEY   2

Definition at line 52 of file shadow.c.

#define EXP_KEY   7

Definition at line 57 of file shadow.c.

#define FLG_KEY   8

Definition at line 58 of file shadow.c.

#define GET_OPTIONAL_DATE (   var,
  key 
)
Value:
a = attr_find(entry->e_attrs, cbp->mi->mi_attrs[key].an_desc); \
       if ( !a || BER_BVISNULL(&a->a_vals[0])) \
              var = default_nums[key]; \
       else \
       { \
              if (a->a_numvals > 1) \
              { \
                     Debug(LDAP_DEBUG_ANY,"shadow entry %s contains multiple %s values\n", \
                            entry->e_name.bv_val, cbp->mi->mi_attrs[key].an_desc->ad_cname.bv_val,0); \
              } \
              var=to_date(&a->a_vals[0],cbp->mi->mi_attrs[key].an_desc); \
       }

Definition at line 138 of file shadow.c.

#define GET_OPTIONAL_LONG (   var,
  key 
)
Value:
a = attr_find(entry->e_attrs, cbp->mi->mi_attrs[key].an_desc); \
       if ( !a || BER_BVISNULL(&a->a_vals[0])) \
              var = default_nums[key]; \
       else \
       { \
              if (a->a_numvals > 1) \
              { \
                     Debug(LDAP_DEBUG_ANY,"shadow entry %s contains multiple %s values\n", \
                            entry->e_name.bv_val, cbp->mi->mi_attrs[key].an_desc->ad_cname.bv_val,0); \
              } \
              var=strtol(a->a_vals[0].bv_val,&tmp,0); \
              if ((a->a_vals[0].bv_val[0]=='\0')||(*tmp!='\0')) \
              { \
                     Debug(LDAP_DEBUG_ANY,"shadow entry %s contains non-numeric %s value\n", \
                            entry->e_name.bv_val, cbp->mi->mi_attrs[key].an_desc->ad_cname.bv_val,0); \
                     return 0; \
              } \
       }

Definition at line 118 of file shadow.c.

#define INA_KEY   6

Definition at line 56 of file shadow.c.

#define MAX_KEY   4

Definition at line 54 of file shadow.c.

#define MIN_KEY   3

Definition at line 53 of file shadow.c.

#define PWD_KEY   1

Definition at line 51 of file shadow.c.

#define UF_DONT_EXPIRE_PASSWD   0x10000

Definition at line 115 of file shadow.c.

#define UID_KEY   0

Definition at line 50 of file shadow.c.

#define WRN_KEY   5

Definition at line 55 of file shadow.c.


Function Documentation

NSSOV_CBPRIV ( shadow  ,
char buf;struct berval name [256] 
)
static long to_date ( struct berval date,
AttributeDescription attr 
) [static]

Definition at line 74 of file shadow.c.

{
       long value;
       char *tmp;
       /* do some special handling for date values on AD */
       if (strcasecmp(attr->ad_cname.bv_val,"pwdLastSet")==0)
       {
              char buffer[8];
              size_t l;
              /* we expect an AD 64-bit datetime value;
                      we should do date=date/864000000000-134774
                      but that causes problems on 32-bit platforms,
                      first we devide by 1000000000 by stripping the
                      last 9 digits from the string and going from there */
              l=date->bv_len-9;
              if (l<1 || l>(sizeof(buffer)-1))
                     return 0; /* error */
              strncpy(buffer,date->bv_val,l);
              buffer[l]='\0';
              value=strtol(buffer,&tmp,0);
              if ((buffer[0]=='\0')||(*tmp!='\0'))
              {
                     Debug(LDAP_DEBUG_ANY,"shadow entry contains non-numeric %s value\n",
                            attr->ad_cname.bv_val,0,0);
                     return 0;
              }
              return value/864-134774;
              /* note that AD does not have expiry dates but a lastchangeddate
                      and some value that needs to be added */
       }
       value=strtol(date->bv_val,&tmp,0);
       if ((date->bv_val[0]=='\0')||(*tmp!='\0'))
       {
              Debug(LDAP_DEBUG_ANY,"shadow entry contains non-numeric %s value\n",
                     attr->ad_cname.bv_val,0,0);
              return 0;
       }
       return value;
}

Here is the call graph for this function:

static int write_shadow ( nssov_shadow_cbp *  cbp,
Entry entry 
) [static]

Definition at line 156 of file shadow.c.

{
       struct berval tmparr[2];
       struct berval *names;
       Attribute *a;
       char *tmp;
       struct berval passwd = {0};
       long lastchangedate;
       long mindays;
       long maxdays;
       long warndays;
       long inactdays;
       long expiredate;
       unsigned long flag;
       int i;
       int32_t tmpint32;
       /* get username */
       if (BER_BVISNULL(&cbp->name))
       {
              a = attr_find(entry->e_attrs, cbp->mi->mi_attrs[UID_KEY].an_desc);
              if (!a)
              {
                     Debug(LDAP_DEBUG_ANY,"shadow entry %s does not contain %s value\n",
                            entry->e_name.bv_val, cbp->mi->mi_attrs[UID_KEY].an_desc->ad_cname.bv_val,0);
                     return 0;
              }
              names = a->a_vals;
       }
       else
       {
              names=tmparr;
              names[0]=cbp->name;
              BER_BVZERO(&names[1]);
       }
       /* get password */
       a = attr_find(entry->e_attrs, cbp->mi->mi_attrs[PWD_KEY].an_desc);
       if ( a )
              get_userpassword(&a->a_vals[0], &passwd);
       if (BER_BVISNULL(&passwd))
              passwd=default_shadow_userPassword;
       /* get lastchange date */
       GET_OPTIONAL_DATE(lastchangedate,CHG_KEY);
       /* get mindays */
       GET_OPTIONAL_LONG(mindays,MIN_KEY);
       /* get maxdays */
       GET_OPTIONAL_LONG(maxdays,MAX_KEY);
       /* get warndays */
       GET_OPTIONAL_LONG(warndays,WRN_KEY);
       /* get inactdays */
       GET_OPTIONAL_LONG(inactdays,INA_KEY);
       /* get expire date */
       GET_OPTIONAL_LONG(expiredate,EXP_KEY);
       /* get flag */
       GET_OPTIONAL_LONG(flag,FLG_KEY);
       /* if we're using AD handle the flag specially */
       if (strcasecmp(cbp->mi->mi_attrs[CHG_KEY].an_desc->ad_cname.bv_val,"pwdLastSet")==0)
       {
              if (flag&UF_DONT_EXPIRE_PASSWD)
                     maxdays=99999;
              flag=0;
       }
       /* write the entries */
       for (i=0;!BER_BVISNULL(&names[i]);i++)
       {
              WRITE_INT32(cbp->fp,NSLCD_RESULT_BEGIN);
              WRITE_BERVAL(cbp->fp,&names[i]);
              WRITE_BERVAL(cbp->fp,&passwd);
              WRITE_INT32(cbp->fp,lastchangedate);
              WRITE_INT32(cbp->fp,mindays);
              WRITE_INT32(cbp->fp,maxdays);
              WRITE_INT32(cbp->fp,warndays);
              WRITE_INT32(cbp->fp,inactdays);
              WRITE_INT32(cbp->fp,expiredate);
              WRITE_INT32(cbp->fp,flag);
       }
       return 0;
}

Here is the call graph for this function:


Variable Documentation

static struct berval = BER_BVC("(objectClass=shadowAccount)") [static]

Definition at line 34 of file shadow.c.

int default_nums[] [static]
Initial value:
 { 0,0,
       -1, 
       -1, 
       -1, 
       -1, 
       -1, 
       -1, 
       0 
}

Definition at line 62 of file shadow.c.