NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Common.IO.Permission Class Reference

Static Public Member Functions

static bool ChangeFileMode (string file, uint mode)
 
static bool ChangeFileOwner (string file, uint user, uint?group)
 
static uint GetGroupId (string groupName)
 
static uint GetUserId (string userName)
 
static bool SetUserId (uint userId)
 

Detailed Description

Definition at line 27 of file Permission.cs.

Member Function Documentation

static bool Ntp.Common.IO.Permission.ChangeFileMode ( string  file,
uint  mode 
)
inlinestatic

Definition at line 29 of file Permission.cs.

Referenced by Ntp.Analyzer.Export.FileSystemDestination.ApplyPermissions().

30  {
31  // Changing file mode is only supported on Unix platforms
32  if (Environment.OSVersion.Platform != PlatformID.Unix)
33  return true;
34 
35  var permissions = NativeConvert.FromOctalPermissionString(mode.ToString());
36  return Syscall.chmod(file, permissions) == 0;
37  }

Here is the caller graph for this function:

static bool Ntp.Common.IO.Permission.ChangeFileOwner ( string  file,
uint  user,
uint?  group 
)
inlinestatic

Definition at line 39 of file Permission.cs.

Referenced by Ntp.Analyzer.Export.FileSystemDestination.ApplyPermissions().

40  {
41  // Changing file owner is only supported on Unix platforms
42  if (Environment.OSVersion.Platform != PlatformID.Unix)
43  return true;
44 
45  return Syscall.chown(file, user, group ?? unchecked((uint) -1)) == 0;
46  }

Here is the caller graph for this function:

static uint Ntp.Common.IO.Permission.GetGroupId ( string  groupName)
inlinestatic

Definition at line 48 of file Permission.cs.

Referenced by Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode.InternalResolve().

49  {
50  // Group IDs are only supported on Unix platforms
51  if (Environment.OSVersion.Platform != PlatformID.Unix)
52  return 0;
53 
54  var gr = Syscall.getgrnam(groupName);
55  return gr?.gr_gid;
56  }

Here is the caller graph for this function:

static uint Ntp.Common.IO.Permission.GetUserId ( string  userName)
inlinestatic

Definition at line 58 of file Permission.cs.

Referenced by Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode.InternalResolve().

59  {
60  // User IDs are only supported on Unix platforms
61  if (Environment.OSVersion.Platform != PlatformID.Unix)
62  return 0;
63 
64  var pw = Syscall.getpwnam(userName);
65  return pw?.pw_uid;
66  }

Here is the caller graph for this function:

static bool Ntp.Common.IO.Permission.SetUserId ( uint  userId)
inlinestatic

Definition at line 68 of file Permission.cs.

Referenced by Ntp.Analyzer.Process.Initializer.InitializeLog(), and Ntp.Analyzer.Process.Initializer.InitializeSecurity().

69  {
70  // Setting user ID is only supported on Unix platforms
71  if (Environment.OSVersion.Platform != PlatformID.Unix)
72  return true;
73 
74  try
75  {
76  Syscall.setuid(userId);
77  }
78  catch
79  {
80  return false;
81  }
82 
83  return true;
84  }

Here is the caller graph for this function:


The documentation for this class was generated from the following file: