top logo menu kitty mascot
AROS.ORG Developers Localization Bounties

security

Index


secAccess_Control() secAddMonitor() secAllocGroupInfo() secAllocUserInfo()
secCheckPasswdA() secContextLocate() secEnumChildren() secFreeExtOwner()
secFreeGroupInfo() secFreeUserInfo() secFreeze() secFSRendezVous()
secGetConfigDirLock() secGetDefProtection() secgetgid() secGetGroupInfo()
secGetPasswdDirLock() secgetpgid() secGetPktDefProtection() secGetPktOwner()
secGetRelationshipA() secGetTaskExtOwner() secGetTaskOwner() secgetuid()
secGetUserInfo() secIsConfigured() secIsVolumeSecured() secKill()
secLimitDOSSetProtection() secLimitProtection() secLoadPlugin() secLocksecBase()
secLoginA() secLogoutA() secPasswd() secPluginOperationComplete()
secRegisterHandler() secRegisterSegment() secRemMonitor() secSetDefProtectionA()
secsetegid() secseteuid() secsetgid() secSetProtection()
secsetreuid() secSetTaskOwnerFromSegment() secsetuid() secSetUIDBegin()
secSetUIDEnd() secUnfreeze() secUnloadPlugin() secUnlocksecBase()
secUnRegisterHandler() secUnregisterSegment() secUserInfo2ExtOwner()  

secAccess_Control()

Synopsis

LONG secAccess_Control(
         ULONG contextflags,
         APTR context,
         struct secExtOwner * task,
         ULONG objectowner,
         LONG objectprot,
         LONG access_type );

Function

Filesystem API: decide whether a task may access an object.

Inputs

contextflags - secAC_IGNORE_CONTEXT or secAC_FILESYSTEM_CONTEXT.
context      - the filesystem's MsgPort for secAC_FILESYSTEM_CONTEXT.
task         - the requesting task's owner (see secGetPktOwner()),
               NULL for nobody.
objectowner  - owner of the object (uid<<16 | gid).
objectprot   - protection bits of the object.
access_type  - secAt_#? flags.

Result

secAC_PERMISSION_GRANTED, or secAC_PERMISSION_DENIED with secAC_#?
detail flags.

secAddMonitor()

Synopsis

BOOL secAddMonitor(
         struct secMonitor * monitor );

Function

Add a monitor: a task interested in login/passwd/owner-change
events. Root only. The structure must stay valid until
secRemMonitor().

Result

success

secAllocGroupInfo()

Synopsis

struct secGroupInfo * secAllocGroupInfo();

Function

Allocate a Group Information Structure. Free it with secFreeGroupInfo().

secAllocUserInfo()

Synopsis

struct secUserInfo * secAllocUserInfo();

Function

Allocate a User Information Structure. Free it with secFreeUserInfo().

Result

info - the structure, or NULL.

secCheckPasswdA()

Synopsis

BOOL secCheckPasswdA(
         struct TagItem * taglist );

BOOL secCheckPasswd(
         TAG tag, ... );

Function

Check the password of the owner of the calling task; asks for it
unless secT_Password is given.

Tags

secT_Input, secT_Output, secT_Graphical, secT_PubScrName - as for
secLoginA(). secT_Password - (STRPTR) the password to check.

Result

valid - TRUE if the password is correct.

secContextLocate()

Synopsis

APTR secContextLocate(
         secPluginModule * module,
         ULONG id,
         struct Task * caller,
         ULONG size );

Function

Plugin API: locate (or allocate) the context memory of size 'size'
that a module keeps for a caller under the given id. The memory is
freed automatically when the caller closes the library or exits.

Result

The context memory, or NULL.

secEnumChildren()

Synopsis

LONG secEnumChildren(
         struct Task * parent,
         struct Task ** children,
         LONG size );

Function

Enumerate the children of a task.

Inputs

parent   - the task, NULL for the current one.
children - array to fill (may be NULL to query the count).
size     - number of entries in the array.

Result

The number of children, negative if the array was too small (the
absolute value is the required size).

secFreeExtOwner()

Synopsis

void secFreeExtOwner(
         struct secExtOwner * owner );

Function

Free an extended owner structure returned by secGetTaskExtOwner(),
secGetPktOwner() or secUserInfo2ExtOwner(). NULL is allowed.

secFreeGroupInfo()

Synopsis

void secFreeGroupInfo(
         struct secGroupInfo * info );

Function

Free a structure allocated with secAllocGroupInfo().

secFreeUserInfo()

Synopsis

void secFreeUserInfo(
         struct secUserInfo * info );

Function

Free a structure allocated with secAllocUserInfo().

secFreeze()

Synopsis

BOOL secFreeze(
         struct Task * task );

Function

Freeze (suspend) a task. Root only.

Result

success. Fails on SMP systems (not supported yet).

secFSRendezVous()

Synopsis

BOOL secFSRendezVous();

Function

Called by a multi-user aware filesystem when it comes up, so that the
library rescans the volumes and key files.

Result

TRUE if the server is running.

secGetConfigDirLock()

Synopsis

BPTR secGetConfigDirLock();

Function

Get a shared lock on the configuration directory.

Result

lock, or BNULL. UnLock() it when done.

secGetDefProtection()

Synopsis

ULONG secGetDefProtection(
         struct Task * task );

Function

Get the default protection bits of a task.

Inputs

task - the task, NULL for the current one.

secgetgid()

Synopsis

UWORD secgetgid();

Function

POSIX: the real group id of the calling task.

secGetGroupInfo()

Synopsis

struct secGroupInfo * secGetGroupInfo(
         struct secGroupInfo * info,
         ULONG keytype );

Function

Fill in a Group Information Structure according to the key.

Result

info, or NULL if no (more) group matches.

secGetPasswdDirLock()

Synopsis

BPTR secGetPasswdDirLock();

Function

Get a shared lock on the directory holding the password file.

Result

lock, or BNULL. UnLock() it when done.

secgetpgid()

Synopsis

int secgetpgid(
         int pid );

Function

POSIX: the session id of a process (0 = the calling one).

Result

The session id, 0 if not in a session, -1 for an unknown pid.

secGetPktDefProtection()

Synopsis

LONG secGetPktDefProtection(
         struct DosPacket * pkt );

Function

Filesystem API: get the default protection bits of the task that
sent a packet, to be used for newly created objects.

secGetPktOwner()

Synopsis

struct secExtOwner * secGetPktOwner(
         struct DosPacket * pkt );

Function

Filesystem API: get the owner of the task that sent a packet. Must
be called before the packet is replied.

Result

owner - free with secFreeExtOwner(). NULL for nobody.

secGetRelationshipA()

Synopsis

ULONG secGetRelationshipA(
         struct secExtOwner * user,
         ULONG owner,
         struct TagItem * taglist );

ULONG secGetRelationship(
         struct secExtOwner * user,
         ULONG owner,
         TAG tag, ... );

Function

Determine the relationship between a user and the owner of an
object.

Inputs

user    - the user (NULL = nobody).
owner   - the object's owner (uid<<16 | gid).
taglist - reserved, pass NULL.

Result

secRelF_#? flags.

secGetTaskExtOwner()

Synopsis

struct secExtOwner * secGetTaskExtOwner(
         struct Task * task );

Function

Get the extended owner (uid, gid and secondary groups) of a task.

Inputs

task - the task, NULL for the current one.

Result

owner - free with secFreeExtOwner(). NULL if owned by nobody.

secGetTaskOwner()

Synopsis

ULONG secGetTaskOwner(
         struct Task * task );

Function

Get the owner of a task.

Inputs

task - the task, NULL for the current one.

Result

owner - uid<<16 | gid, secOWNER_NOBODY if the task is owned by nobody.

secgetuid()

Synopsis

UWORD secgetuid();

Function

POSIX: the real user id of the calling task.

secGetUserInfo()

Synopsis

struct secUserInfo * secGetUserInfo(
         struct secUserInfo * info,
         ULONG keytype );

Function

Fill in a User Information Structure according to the key. Repeated
calls with secKeyType_Next (and the #?Next keys) iterate.

Inputs

info    - structure allocated with secAllocUserInfo(), the key field
          filled in.
keytype - secKeyType_#?, see <libraries/security.h>.

Result

info, or NULL if no (more) user matches.

secIsConfigured()

Synopsis

BOOL secIsConfigured();

Function

Is the system configured for multi-user operation, i.e. has a
password file been found and parsed? On an unconfigured system
every task is treated as privileged and no access checks are made.

Result

TRUE if configured and no security violation was detected.

secIsVolumeSecured()

Synopsis

BOOL secIsVolumeSecured(
         CONST_STRPTR volname,
         ULONG dostype );

Function

Filesystem API: should the handler of this volume enforce
ownership? TRUE for multi-user dostypes (muF#?, muAF, muPF) and for
volumes that carry a valid key file (secKey_FileName) in their root
directory, which is how a filesystem without a multi-user dostype
(e.g. SFS) is marked as multi-user. The server (re)scans volumes at
startup and whenever secFSRendezVous() is called, so a handler should
call secFSRendezVous() when a volume comes online and ask again.

Inputs

volname - the volume or device name, with or without ':' (may be NULL)
dostype - the volume's dostype

Result

TRUE if the handler should enforce. Note that enforcement only
makes sense while secIsConfigured() is TRUE as well.

secKill()

Synopsis

BOOL secKill(
         struct Task * task );

Function

Kill a task. Root only. Processes are asked to quit with
SIGBREAKF_CTRL_C; plain tasks are removed with RemTask().

Result

success

secLimitDOSSetProtection()

Synopsis

BOOL secLimitDOSSetProtection(
         BOOL flag );

Function

Limit dos.library/SetProtection() to changing only the protection
bits for the owner of a file; the GROUP and OTHER bits can then only
be changed via secSetProtection(). Root only.

Inputs

flag - TRUE to turn limiting on.

Result

success

secLimitProtection()

Synopsis

LONG secLimitProtection(
         CONST_STRPTR name,
         LONG protect );

Function

Used by dos.library/SetProtection(): apply the LIMITDOSSETPROTECTION
policy. If limiting is on and the caller is neither root nor inside
secSetProtection(), the GROUP and OTHER bits of the existing object
are preserved.

Inputs

name    - the object SetProtection() is about to change.
protect - the requested protection bits.

Result

The protection bits to apply.

secLoadPlugin()

Synopsis

BOOL secLoadPlugin(
         CONST_STRPTR name );

Function

Load and initialise a plugin from the configuration directory.
Root only.

Inputs

name - the plugin name without the .secplugin suffix.

secLocksecBase()

Synopsis

struct secPointers * secLocksecBase();

Function

Lock the library's internal lists for inspection by privileged
tools. Root only. Release with secUnlocksecBase() as soon as
possible.

Result

pointers to the lists, or NULL.

secLoginA()

Synopsis

ULONG secLoginA(
         struct TagItem * taglist );

ULONG secLogin(
         TAG tag, ... );

Function

Login to the system and remember the previous user of the task.

Tags

secT_Graphical  - (BOOL) use a graphical login instead of a console
                  one. Default FALSE.
secT_Input      - (BPTR) filehandle to read from. Default Input().
secT_Output     - (BPTR) filehandle to write to. Default Output().
secT_PubScrName - (STRPTR) public screen for the requester.
secT_Task       - (struct Task *) the task to login. Only your own
                  tasks or tasks owned by nobody, unless you are root.
                  Default: the current task.
secT_Own        - (BOOL) make the task owned by the caller's owner.
secT_Global     - (BOOL) also login all descendants of the task.
secT_UserID     - (STRPTR) do not ask for a UserID.
secT_Password   - (STRPTR) do not ask for a password (needs secT_UserID).
secT_NoLog      - (BOOL) do not log this action (root only).

Result

The user that logged in (uid<<16 | gid), or secOWNER_NOBODY for a
failure.

Notes

On an unconfigured system (no password file) any login succeeds as
root, so that Security-Startup scripts work before the system is set
up.

See also

secLogoutA()


secLogoutA()

Synopsis

ULONG secLogoutA(
         struct TagItem * taglist );

ULONG secLogout(
         TAG tag, ... );

Function

Logout and restore the previous user. If there was no previous user
or the previous user was nobody, a login request will appear (unless
secT_Quiet). A login from this request also sets the local variable
"Home", the current directory, shows the last login information and
executes the .profile from the configuration directory.

Inputs

taglist - see secLoginA(); additionally
    secT_Quiet - (BOOL) never request a login, simply logout.
    secT_All   - (BOOL) logout all previous users.

Result

The user you are now (uid<<16 | gid), secOWNER_NOBODY for nobody.

See also

secLoginA()


secPasswd()

Synopsis

BOOL secPasswd(
         STRPTR oldpwd,
         STRPTR newpwd );

Function

Change the password of the owner of the calling task.

Inputs

oldpwd - the old password.
newpwd - the new password.

Result

success - TRUE if the password was changed.

secPluginOperationComplete()

Synopsis

void secPluginOperationComplete(
         APTR context,
         ULONG result );

Function

Plugin API: complete an operation that returned secpiASYNC.

Inputs

context - the server packet handed to the plugin.
result  - the secpi#? result.

secRegisterHandler()

Synopsis

ULONG secRegisterHandler(
         struct plugin_ops * ops );

Function

Plugin API: register an operation table with the subsystem named
by its HandlerType.

Result

secpiTRUE on success.

secRegisterSegment()

Synopsis

BOOL secRegisterSegment(
         BPTR seglist,
         BPTR fh );

Function

Called by dos.library after loading an executable. If the file has
the secFIBF_SET_UID bit set and a real owner, the seglist is
remembered as a setuid executable.

Inputs

seglist - the loaded segment list
fh      - the file it was loaded from (still open)

Result

TRUE if the segment was registered as setuid.

secRemMonitor()

Synopsis

void secRemMonitor(
         struct secMonitor * monitor );

Function

Remove a monitor added with secAddMonitor().

secSetDefProtectionA()

Synopsis

BOOL secSetDefProtectionA(
         struct TagItem * taglist );

BOOL secSetDefProtection(
         TAG tag, ... );

Function

Set the default protection bits ('umask') used for new files.

Tags

secT_Task          - (struct Task *) the task, default the current one.
secT_DefProtection - (ULONG) the protection bits, default
                     FIBF_OTR_READ|FIBF_GRP_READ.
secT_Global        - (BOOL) also change all descendants of the task.

Result

success

secsetegid()

Synopsis

int secsetegid(
         UWORD gid );

Function

POSIX: set the effective group id.

secseteuid()

Synopsis

int secseteuid(
         UWORD uid );

Function

POSIX: set the effective user id.

secsetgid()

Synopsis

int secsetgid(
         UWORD gid );

Function

POSIX: set the group id (see secsetuid()).

secSetProtection()

Synopsis

BOOL secSetProtection(
         CONST_STRPTR name,
         LONG mask );

Function

Change the protection bits of a file or directory, including the
GROUP and OTHER bits, regardless of secLimitDOSSetProtection().

Inputs

name - the file or directory.
mask - the new protection bits.

Result

success

secsetreuid()

Synopsis

int secsetreuid(
         int ruid,
         int euid );

Function

POSIX: set the real and effective user ids. -1 leaves an id
unchanged.

secSetTaskOwnerFromSegment()

Synopsis

BOOL secSetTaskOwnerFromSegment(
         struct Task * task,
         BPTR seglist );

Function

Called by dos.library's CreateNewProc() (under Forbid(), before the
new process runs) when the process is created from a seglist. If
the seglist is a setuid executable the new process gets the owner
of the executable.

Result

TRUE if the owner was changed.

secsetuid()

Synopsis

int secsetuid(
         UWORD uid );

Function

POSIX: set the user id. Root may set any id (real, effective and
saved); others may only switch between their real and saved ids.

Result

0 on success, -1 on failure.

secSetUIDBegin()

Synopsis

APTR secSetUIDBegin(
         BPTR seglist );

Function

Called by dos.library's RunCommand() before running a seglist. If
the seglist is a setuid executable the calling task's effective
owner is switched to the owner of the executable.

Result

A cookie to pass to secSetUIDEnd() when the command returns, or
NULL if nothing was changed.

secSetUIDEnd()

Synopsis

void secSetUIDEnd(
         APTR cookie );

Function

Restore the credentials saved by secSetUIDBegin().

secUnfreeze()

Synopsis

BOOL secUnfreeze(
         struct Task * task );

Function

Unfreeze a task frozen with secFreeze(). Root only.

Result

success

secUnloadPlugin()

Synopsis

BOOL secUnloadPlugin(
         CONST_STRPTR name );

Function

Unload a plugin loaded with secLoadPlugin(). Root only.

secUnlocksecBase()

Synopsis

void secUnlocksecBase(
         struct secPointers * secP );

Function

Release the lists locked with secLocksecBase().

secUnRegisterHandler()

Synopsis

void secUnRegisterHandler(
         struct plugin_ops * ops );

Function

Plugin API: unregister an operation table.

secUnregisterSegment()

Synopsis

void secUnregisterSegment(
         BPTR seglist );

Function

Called by dos.library before a seglist is unloaded.

secUserInfo2ExtOwner()

Synopsis

struct secExtOwner * secUserInfo2ExtOwner(
         struct secUserInfo * info );

Function

Convert a User Information Structure to an extended owner.

Result

owner - free with secFreeExtOwner().