@@ -131,6 +131,13 @@ public override void CreateEmptyStoreFile(string path, string linuxFilePermissio
131131 linuxFileGroup = $ "-g { linuxGroupOwner [ 1 ] } ";
132132 }
133133
134+ string pathOnly = string . Empty ;
135+ string fileName = string . Empty ;
136+ SplitStorePathFile ( path , out pathOnly , out fileName ) ;
137+
138+ linuxFilePermissions = string . IsNullOrEmpty ( linuxFilePermissions ) ? GetFolderPermissions ( pathOnly ) : linuxFilePermissions ;
139+ linuxFileOwner = string . IsNullOrEmpty ( linuxFileOwner ) ? GetFolderOwner ( pathOnly ) : linuxFileOwner ;
140+
134141 AreLinuxPermissionsValid ( linuxFilePermissions ) ;
135142 RunCommand ( $ "install -m { linuxFilePermissions } -o { linuxFileOwner } { linuxFileGroup } /dev/null { path } ", null , ApplicationSettings . UseSudo , null ) ;
136143
@@ -151,5 +158,52 @@ public override void RemoveCertificateFile(string path, string fileName)
151158
152159 RunCommand ( $ "rm { path } { fileName } ", null , ApplicationSettings . UseSudo , null ) ;
153160 }
161+
162+ private string GetFolderPermissions ( string path )
163+ {
164+ _logger . MethodEntry ( LogLevel . Debug ) ;
165+
166+ try
167+ {
168+ return RunCommand ( $ "stat -c '%a' { path } ", null , ApplicationSettings . UseSudo , null ) . Replace ( $ "\n ", string . Empty ) ;
169+ }
170+ finally
171+ {
172+ _logger . MethodExit ( LogLevel . Debug ) ;
173+ }
174+ }
175+
176+ private string GetFolderOwner ( string path )
177+ {
178+ _logger . MethodEntry ( LogLevel . Debug ) ;
179+
180+ try
181+ {
182+ return RunCommand ( $ "stat -c '%U' { path } ", null , ApplicationSettings . UseSudo , null ) . Replace ( $ "\n ", string . Empty ) ;
183+ }
184+ finally
185+ {
186+
187+ _logger . MethodExit ( LogLevel . Debug ) ;
188+ }
189+ }
190+
191+ private void SplitStorePathFile ( string pathFileName , out string path , out string fileName )
192+ {
193+ _logger . MethodEntry ( LogLevel . Debug ) ;
194+
195+ try
196+ {
197+ int separatorIndex = pathFileName . LastIndexOf ( pathFileName . Substring ( 0 , 1 ) == "/" ? @"/" : @"\" ) ;
198+ fileName = pathFileName . Substring ( separatorIndex + 1 ) ;
199+ path = pathFileName . Substring ( 0 , separatorIndex + 1 ) ;
200+ }
201+ catch ( Exception ex )
202+ {
203+ throw new RemoteFileException ( $ "Error attempting to parse certficate store/key path={ pathFileName } .", ex ) ;
204+ }
205+
206+ _logger . MethodEntry ( LogLevel . Debug ) ;
207+ }
154208 }
155209}
0 commit comments