---
name: "security_sid_to_context"
section: "2"
platform: "linux"
package: "libselinux-dev"
version: "2002031409-4"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/security_sid_to_context"
---

# security\_sid\_to\_context(2)

Get the security context string for a SID

## NAME

security\_sid\_to\_context - Get the security context string for a SID

## SYNOPSIS

**#include \<ss.h\>**

**int security\_sid\_to\_context(security\_id\_t** *sid***, security\_context\_t** *scontext***, \_\_u32 \****scontext\_len***);**

## DESCRIPTION

The  **security\_sid\_to\_context** call is used to obtain the security context string representation of the context associated with *sid.* The *scontext\_len* argument is a value-result parameter, initialized to the size of the buffer associated with *scontext*, and modified on return to indicate the length of the context stored there, including the terminating NULL character.   If the buffer is not large enough, then  *scontext\_len* is set to the actual size, -1 is returned, and  *errno* is set to ENOSPC.

## RETURN VALUE

A zero is returned on success.  On error, -1 is returned, and   *errno* is set appropriately.

## ERRORS

- **EINVAL**

  The SID was invalid.

- **EACCES**

  The process is not authorized to invoke this call on this SID.

- **ENOSPC**

  The buffer was too small.

## SEE ALSO

[**security\_compute\_av**(2)](/security_compute_av/2.md), [**security\_sid\_to\_context**(2)](/security_sid_to_context/2.md), [**security\_context\_to\_sid**(2)](/security_context_to_sid/2.md), [**security\_transition\_sid**(2)](/security_transition_sid/2.md), [**security\_member\_sid**(2)](/security_member_sid/2.md), [**security\_load\_policy**(2)](/security_load_policy/2.md), [**security\_notify\_perm**(2)](/security_notify_perm/2.md), [**security\_get\_sids**(2)](/security_get_sids/2.md)
