user_ty Class Reference
#include <user.h>
Detailed Description
The
user_ty class represents a user (usually, the operating system's idea of a user) an information about that user, and her preferences.
Definition at line 37 of file user.h.
Member Typedef Documentation
The pointer typedef is to be used whenevr pointing to a user_ty object. This allows the pointer type to be changed to a smart pointer in the future.
Definition at line 45 of file user.h.
Constructor & Destructor Documentation
The destructor.
It is not virtual, thou shalt not derived from this class.
user_ty::user_ty |
( |
|
) |
[private] |
user_ty::user_ty |
( |
int |
uid |
) |
[private] |
The constructor.
- Parameters:
-
| uid | The user ID involved. |
user_ty::user_ty |
( |
int |
uid, |
|
|
int |
gid | |
|
) |
| | [private] |
The constrctor.
- Parameters:
-
| uid | system user id |
| gid | system group id |
Member Function Documentation
The create class method is used to create new heap instances of users. The user in this case being the user who executeed this program.
The create class method is used to create new heap instances of users. The default group is derived from the password file.
- Parameters:
-
| uid | The user ID involved. |
The create class method is used to create a user structure for the aegis/gonzo.cc file. It has a known uid and gid, and will succeed, even if there are no relvant entries in system tables.
- Parameters:
-
| uid | system user id |
| gid | system group id |
The create class method is used to create a user instance from a login name.
The login name is mapped to a uid. The password file is searched from beginning to end, so the cannonical name is the first found in the password file. The cannonical name is used even for user structures created with this function.
- Parameters:
-
| login_name | user's login name |
The create_by_directory class method is used to create a user from the ownership of a directory.
- Parameters:
-
| path | The absolute path pf the directory of interest. |
- Returns:
- pointer to new user_ty instance
static void user_ty::progress_option_set |
( |
void(*)(void) |
usage |
) |
[static] |
The progress_option_set class method is called by command line processing to indicate that a --progress command line option has been seen.
- Parameters:
-
| usage | The function to call if a fail via a usage message is required. |
static void user_ty::progress_option_clear |
( |
void(*)(void) |
usage |
) |
[static] |
The progress_option_clear class method is called by command line processing to indicate that a --no-progress command line option has been seen.
- Parameters:
-
| usage | The function to call if a fail via a usage message is required. |
bool user_ty::progress_get |
( |
|
) |
|
The progress_get method is used to determine whether or not progress messages should be displayed. It consults the command line settings and also the user's progress attribute. Being in the background is not considered. The --verbose option is not considered. The default is to return false.
Example: attribute = [ { name = "progress-preference"; value = "true"; } ];
The name method is used to obtain the login name of this user.
nstring user_ty::full_name |
( |
|
) |
const |
The full_name method is used to obtain the human readable name of this user, as recorded in the password file.
The full_name class method is used to obtain the full name of a user, given the login name.
- Parameters:
-
| login | The login name of the user |
- Returns:
- the full name of the user, or the empty string if it doesn't exist.
int user_ty::get_uid |
( |
|
) |
const |
The get_uid method is used to obtain the operating system user ID associated with this user.
bool user_ty::check_uid |
( |
|
) |
const |
The check_uid method is used to verify that this user has an acceptable level of privilege.
int user_ty::get_gid |
( |
|
) |
const |
The get_gid method is used to obtain the operating system group ID associated with this user.
bool user_ty::check_gid |
( |
|
) |
const |
The check_gid method is used to verify that this user has an acceptable level of privilege.
nstring user_ty::get_group_name |
( |
|
) |
const |
The get_group_name method is used to obtain the name of the operating system group attached to this user.
void user_ty::set_gid |
( |
int |
gid, |
|
|
bool |
weak = false | |
|
) |
| | |
The set_gid method is used to set the group ID of this user.
- Parameters:
-
| gid | The group ID to use. |
| weak | true if it is OK that the group doesn't exists, false (default) if it is an error if the group desn't exist. |
void user_ty::umask_set |
( |
int |
um |
) |
|
The umask_set method is used to set the file creation mode mosk.
- Parameters:
-
int user_ty::umask_get |
( |
|
) |
const |
The umask_get method is used to obtain the new file creation permissions mode mask for this user.
nstring user_ty::get_home |
( |
|
) |
const |
The get_home method is used to obtain the absolute path of this user's home directory.
nstring user_ty::get_email_address |
( |
|
) |
|
The get_email_address method is used to read the user's preferences for her email address. Defaults to full name from /etc/passwd, then login name at hostname (not generally useful).
void user_ty::ustate_write |
( |
|
) |
|
The ustate_write method is used to write any modified ustate file contents back to disk.
void user_ty::own_add |
( |
project_ty * |
pp, |
|
|
long |
chanum | |
|
) |
| | |
The user_own_add function is used to add a change to the user's list of owned changes.
- Parameters:
-
bool user_ty::own_nth |
( |
project_ty * |
pp, |
|
|
long |
n, |
|
|
long & |
chanum | |
|
) |
| | |
The user_own_nth function is used to fetch the n'th change owned by a user. The project name is derived from the user structure.
- Parameters:
-
| pp | project of the change |
| n | selector change_number reference to where to put number of the change |
- Returns:
- true on sucess, false if no such n.
void user_ty::own_remove |
( |
project_ty * |
pp, |
|
|
long |
chanum | |
|
) |
| | |
The user_own_remove function is used to remove a change from the user's owned change list.
- Parameters:
-
The default_change method is used to find the default change number. It is a fatal error if there isn't one.
- Parameters:
-
- Returns:
- the change number.
nstring user_ty::default_project |
( |
|
) |
|
The default_project method is used to determine the default project of the specified user. It is a fatal error if there is no default project name for the user.
The default_development_directory method is used to determine the absolute path of the user's default development directory.
If the user has not explicitly set one, and the project does not have one set, the user's home directory will be returned.
- Parameters:
-
| pp | The project to consult for its default development directory, as wel. |
nstring user_ty::default_project_directory |
( |
|
) |
|
The default_project_directory method is used to determine the absolute path for where to place new projects.
if the user has not explicitly set one, the user's home directory will be returned.
void user_ty::become_begin |
( |
|
) |
|
The become_begin method is used to set the effective uid and gid to be those of this user. In this way, the code can impersonate a variety of users, while still enforcing strict secure semantics.
void user_ty::become_end |
( |
|
) |
|
The become_end method is used to reverse the effects of the become_begin method.
These two methods shall always be used in pairs. This is simplified further if you use the user_ty::become class.
bool user_ty::delete_file_query |
( |
const nstring & |
filename, |
|
|
bool |
isdir, |
|
|
int |
default_preference | |
|
) |
| | |
The delete_file_query method is used to determine whether a file should be deleted or not.
- Parameters:
-
| filename | The name of the file to be deleted |
| isdir | whether the file is a directory (true) or a regular file (false). |
| default_preference | If the user gave no preference on the command line, use this instead. 1 -> true, 0 -> false, -1 -> look in .aegisrc |
- Returns:
- true if the file should be deleted, or false if it should not.
static void user_ty::delete_file_argument |
( |
void(*)(void) |
usage |
) |
[static] |
The delete_file_argument class method is used to process --keep and --no-keep command line options.
- Parameters:
-
| usage | Exit via this function on error. |
void user_ty::ustate_lock_prepare |
( |
|
) |
|
The ustate_lock_prepare method is used to notify the lock manager that a ustate lock will be required.
static void user_ty::lock_wait_argument |
( |
void(*)(void) |
usage |
) |
[static] |
The lock_wait_argument class method is used to process --wait and --no-wait command line arguments.
- Parameters:
-
| usage | Exit via this function on error. |
bool user_ty::lock_wait |
( |
|
) |
|
The lock_wait method may be used if this user wants to wait for locks or not.
nstring user_ty::editor_command |
( |
|
) |
|
The editor_command method is used to read the user's preferences for editor to use with aegis. Defaults to EDITOR environment variable, or else "ed".
nstring user_ty::visual_command |
( |
|
) |
|
The visual_command method is used to read the user's preferences for a visual editor to use with aegis. Defaults to VISUAL environment variable, or else the EDITOR environment variable, or else "vi".
The diff_preference method is ised to obtain this user's aed preference.
- Returns:
- The choices are always merge, never merge, and automatic (default).
bool user_ty::pager_preference |
( |
|
) |
|
The pager_preference method is used to obtain this user's pager preference.
- Returns:
- true if should use pager, false if should not use pager.
The pager_command method is used to read the user's preferences for pager to use with aegis. Defaults to PAGER environment variable. If $PAGER is not set then "more" is used.
bool user_ty::persevere_preference |
( |
bool |
dflt |
) |
|
The persevere_preference method is used to determine whether or not aet (and friends) should persevere in the face of errors.
- Parameters:
-
| dflt | The default to use, should the not have set a preference. |
static void user_ty::persevere_argument |
( |
void(*)(void) |
usage |
) |
[static] |
The persevere_argument class method is used to process --presevere and -no-persevere command line arguments.
- Parameters:
-
| usage | Exit via this function on error. |
The log_file_preference method may be used to obtain this user's log file preference.
- Parameters:
-
| dflt | If the user has not specified one, this argument is the default to be returned (varies with command). |
- Returns:
- the choices are: none, replace, append
static void user_ty::relative_filename_preference_argument |
( |
void(*)(void) |
usage |
) |
[static] |
The relative_filename_preference_argument class method is used to process --base-relative and --not-base-relative command line options.
- Parameters:
-
| usage | Exit via this function on error. |
The relative_filename_preference method may be used to obtain this user's preference for whethger or not relative file names on the command line are relative to the development diorectory root, or relative to the current directory.
- Parameters:
-
| dflt | The default to use if the user has not selected on (varies with command). |
- Returns:
- the choices are: base, current
static void user_ty::symlink_pref_argument |
( |
void(*)(void) |
usage |
) |
[static] |
The symlink_pref_argument is used to process the --symbolic-links and --no-symbolic-links command line options.
- Parameters:
-
| usage | Exit via this function on error. |
bool user_ty::symlink_pref |
( |
bool |
proj_files_changed |
) |
|
The symlink_pref method may be used to obtain this user's symbolic link maintenance preference. Some development directory styles do not have to be maintained.
If your development directory style uses hard links or copies, this method also controls them.
- Parameters:
-
| proj_files_changed | true if any project files have changed recently |
- Returns:
- true to update the links, false to not update the links
static void user_ty::whiteout_argument |
( |
void(*)(void) |
|
) |
[static] |
The symlink_pref_argument is used to process the --whiteout and --no-whiteout command line options.
- Parameters:
-
| usage | Exit via this function on error. |
bool user_ty::whiteout |
( |
int |
dflt = -1 |
) |
|
The whiteout mwthod may be used to determine this user's whiteout file preference.
- Parameters:
-
| dflt | The default the comman wants (true (0) or false (1)) or -1 if the user's .aegisrc file is to be consulted. |
- Returns:
- true if whiteout files are to be used, false if no whiteout files are to be generated.
The uconf_write_xml method may be used to write this user's uconf data out as XML.
- Parameters:
-
| op | Where to write the XML. |
The uconf_get method is used to get the uconf data corresponding to the specified user. It is cached. This should be used sparingly, if at all. It is preferable to use one of the above methods if at all possible.
- Returns:
- pointer to uconf structure in dynamic memory
- Note:
- this method will eventually be PRIVATE
The user_ustate_get function is used to fetch the "ustate" file for this user, caching for future reference.
- Parameters:
-
void user_ty::lock_sync |
( |
|
) |
[private] |
The lock_sync method is used to flush any out-of-date data caching associated with the user structure.
The pool_find class method is used to look into the pool of user_ty instances to determine wether or not the given UID corresponds to an existing user_ty instance.
This is an O(n) search. It is expected that there will be at most 4, so the slow search isn't a problem - a faster search would have a larger k - making it moot.
- Parameters:
-
| uid | The UID to search for |
- Returns:
- pointer if found, NULL if not found
The pool_add class method is used to add a new user_ty instance to the pool.
void user_ty::waiting_for_lock |
( |
|
) |
[private] |
The waiting_for_lock method is used to print a message to inform the user of the progress acquiring the lock.
static void user_ty::waiting_for_lock |
( |
void * |
|
) |
[static, private] |
The waiting_for_lock class method is used to call the waiting_for_lock method.
Field Documentation
The login_name instance variable is used to remember the login name of this user.
Definition at line 641 of file user.h.
The login_full_name instance variable is used to remember the full name of this user, as recorded in the password entry.
Definition at line 647 of file user.h.
The home instance variable is used to remember the absolute path of this user's home directory.
Definition at line 653 of file user.h.
The group_name instance variable is used to remember the name of the operating system group attached to this user.
Definition at line 659 of file user.h.
The user_id instance variable is used to remeber the operating system user ID associated with this user.
Definition at line 665 of file user.h.
The group_id instance variable is used to remeber the operating system group ID associated with this user.
Definition at line 671 of file user.h.
The umask instance variable is used to remember this user's preferred new file mode creation mask.
Definition at line 677 of file user.h.
The ustate_path instance variable is used to remember where the ustate file is that holds this user's index of owned project.
In some ways this is not ideal, since the path depends on which gonzo holds the project record. There is more than one.
Definition at line 686 of file user.h.
The ustate_data instance variable is used to remember the location of the cached ustate data for this user.
In some ways this is not ideal, since the data depends on which gonzo holds the project record. There is more than one.
Definition at line 695 of file user.h.
The ustate_is_new instance variable is used to remember whether or not a new ustate file is to be created.
Definition at line 701 of file user.h.
The ustate_modified instance variable is used to remember whether or not the cahced ustate data has been modified, and needs to be written out.
Definition at line 708 of file user.h.
The uconf_path instance variable is used to remember the absolute path of this user's .aegisrc file.
Definition at line 723 of file user.h.
The uconf_data instance variable is used to remember the base address of the read-in .aegisrc file data. It is cached for efficiency.
Definition at line 730 of file user.h.
The lock_magic instance variable is used to remember the last time the locks changed, so that uconf and ustate data can be invalidated, if necessary. See the lock_sync method.
Definition at line 737 of file user.h.
The pool_nusers class variable is used to remember how many user_ty instaces currently exist.
Definition at line 749 of file user.h.
The pool_nusers_max class variable is used to remember the size allocated for the pool_user array.
assert(pool_nusers <= pool_nusers_max);
Definition at line 757 of file user.h.
The pool_user class variable is used to remember the base address of a dynamically allocated array of pointers to user instances.
assert(!pool_user == !pool_nusers_max);
Definition at line 766 of file user.h.
The documentation for this class was generated from the following file: