Main Page   Compound List   File List   Compound Members   File Members  

userutil.c File Reference

#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <crypt.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "../include/libuser/user_private.h"

Defines

#define LU_DEFAULT_SALT_TYPE   "$1$"
#define LU_DEFAULT_SALT_LEN   8
#define LU_MAX_LOCK_ATTEMPTS   30
#define UNACCEPTABLE   "!*:$,"
#define ACCEPTABLE

Functions

gint lu_str_case_equal (gconstpointer v1, gconstpointer v2)
gint lu_str_equal (gconstpointer v1, gconstpointer v2)
gint lu_strcasecmp (gconstpointer v1, gconstpointer v2)
gint lu_strcmp (gconstpointer v1, gconstpointer v2)
const char* lu_make_crypted (const char *plain, const char *previous)
gpointer lu_util_lock_obtain (int fd, struct lu_error **error)
void lu_util_lock_free (int fd, gpointer lock)
char* lu_util_line_get_matchingx (int fd, const char *part, int field, struct lu_error **error)
char* lu_util_line_get_matching1 (int fd, const char *part, struct lu_error **error)
char* lu_util_line_get_matching3 (int fd, const char *part, struct lu_error **error)
guint lu_strv_len (gchar **v)
char* lu_util_field_read (int fd, const char *first, unsigned int field, struct lu_error **error)
gboolean lu_util_field_write (int fd, const char *first, unsigned int field, const char *value, struct lu_error **error)
char* lu_util_shadow_current_date (struct lu_string_cache *cache)

Detailed Description


Define Documentation

#define ACCEPTABLE
 

Value:

                   "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
                   "abcdefghijklmnopqrstuvwxyz" \
                   "./0123456789"
A list of allowed salt characters, according to SUSv2.

#define UNACCEPTABLE   "!*:$,"
 

A list of disallowed salt characters, if we're violating SUSv2 by allowing more characters to be salt characters.


Function Documentation

const char* lu_make_crypted ( const char * plain,
const char * previous )
 

lu_make_crypted:

Parameters:
plain   A password.
previous   An optional salt to use, which also indicates the crypt() variation to be used.

Generates a hashed version of plain by calling the crypt() function, using the hashing method specified in @previous.

Returns:
a static global string which must not be freed.

gint lu_str_case_equal ( gconstpointer v1,
gconstpointer v2 )
 

A function which returns non-zero if the strings are equal, and zero if they are unequal. Case-insensitive version.

gint lu_str_equal ( gconstpointer v1,
gconstpointer v2 )
 

A function which returns non-zero if the strings are equal, and zero if they are unequal. Case-sensitive version.

gint lu_strcasecmp ( gconstpointer v1,
gconstpointer v2 )
 

A wrapper for strcasecmp().

gint lu_strcmp ( gconstpointer v1,
gconstpointer v2 )
 

A wrapper for strcmp().

guint lu_strv_len ( gchar ** v )
 

lu_strv_len:

Parameters:
v   an array of strings

Count the length of an array of strings.

Returns:
the number of elements in the array, or 0 if @v is NULL.

char* lu_util_field_read ( int fd,
const char * first,
unsigned int field,
struct lu_error ** error )
 

lu_util_field_read:

Parameters:
fd   Descriptor of open, locked file.
first   Contents of the first field to match the right line with.
field   The number of the field. Minimum is 1.

Read the nth colon-separated field on the line which has first as its first field.

Returns:
An allocated string which must be freed with g_free().

gboolean lu_util_field_write ( int fd,
const char * first,
unsigned int field,
const char * value,
struct lu_error ** error )
 

lu_util_field_write:

Parameters:
fd   Descriptor of open, locked file.
first   Contents of the first field to match the right line with.
field   The number of the field. Minimum is 1.
value   The new value for the field.

Modify the nth colon-separated field on the line which has first as its first field.

Returns:
A boolean indicating success or failure.

void lu_util_lock_free ( int fd,
gpointer lock )
 

lu_util_lock_free:

Parameters:
fd   An open file descriptor.
lock   A lock returned by a previous call to lu_util_lock_obtain().

Unlocks a file.

Returns:
void

gpointer lu_util_lock_obtain ( int fd,
struct lu_error ** error )
 

lu_util_lock_obtain:

Parameters:
fd   An open file descriptor.

Locks the passed-in descriptor for writing, and returns an opaque lock pointer if the lock succeeds.

Returns:
an opaque lock pointer if locking succeeds, NULL on failure.

char* lu_util_shadow_current_date ( struct lu_string_cache * cache )
 

lu_util_shadow_current_date:

Parameters:
cache   A string cache where the returned string will be stored.

Returns:
A shadow-style version of today's date (i.e., formatted as the number of days which have passed since 1 January 1970).


Generated at Wed Oct 12 09:59:05 2005 for libuser by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001