summarylogtreecommitdiffstats
path: root/tty_default_permissions.patch
blob: 173f5a8ee16858922a776dddacfc739377485380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--- trueportd.c.orig	2017-07-03 22:10:37.742810625 -0400
+++ trueportd.c	2017-07-03 22:10:37.752810626 -0400
@@ -1292,17 +1292,22 @@ int open_tty()
 	{
 		// if the device nodes do not exist, then create them
 		if( lstat( slave_ttyname, &stat_buf ) < 0 )
 		{
 			trace( tl_status, "Creating slave device node: %s \n", slave_ttyname );
-			sprintf( buf, "mknod %s c %d %d", slave_ttyname, PTYX_SLAVE_MAJOR, minor_number );
+			sprintf( buf, "mknod -m@TRUEPORT_TTY_PERMISSIONS@ %s c %d %d", slave_ttyname, PTYX_SLAVE_MAJOR, minor_number );
 			if( system( buf ) == -1 ) 
 			{
 				trace( tl_error, "Could not create slave device node: %s\n", slave_ttyname  );
 				trace( tl_error, "  - %s\n", strerror( errno ) );
 				exit(-1);
 			}
+#include <grp.h>
+{
+  struct group *g=getgrnam("@TRUEPORT_TTY_GROUP@");
+  if (g) chown(slave_ttyname,-1,g->gr_gid);
+}
 		}
 
 		if( lstat( master_ttyname, &stat_buf ) < 0 )
 		{
 			trace( tl_status, "Creating master device node: %s \n", master_ttyname );