Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Wednesday, July 27, 2022

getaccess_times (3C)


getaccess_times - return the time for a service used by the specified username.


#include <user_attr.h>

access_times_t *getaccess_times(const char *username,
     const char *service);


The getaccess_times() function returns the times for which the specified service may be used by the specified username.

The internal representation of the time values is in a access_times_t structure defined in <user_attr.h> with the following members:

typedef struct access_times {
	struct {
		int     start;
		int     end;
	} range[7];
} access_times_t;

The caller is responsible to free the returned access_times_t structure.

Return Values

The entries in the range array correspond to the seven days of the week, beginning with Sunday. The start and end times indicate minutes since midnight. If the end time is less than the start time, then the end time applies to the following day. For days that have no valid range, both the start and end times are set to -1.

If the username has no matching entry for the service then the function returns NULL.


The access time policies are specified using the access_times keyword in user_attr(5) and prof_attr(5). The administrative interfaces are usermod(8), rolemod(8), and profiles(1). The getaccess_times() function is intended to be used to validate the policy with respect to the current time, which is retrieved via localtime(3C). By convention, if the getaccess_times() function returns NULL, then no time restrictions apply for the service.


See attributes(7) for description of the following attributes:


See Also

profiles(1), prof_attr(5), user_attr(5), attributes(7), pam_unix_account(7), rolemod(8), usermod(8)