bug 222012. Better enforce persistent directory location
This commit is contained in:
		| @@ -1,3 +1,9 @@ | |||||||
|  | ------------------------------------------------------------------- | ||||||
|  | Thu Jan  4 13:37:03 MST 2007 - jnorman@novell.com | ||||||
|  |  | ||||||
|  | - Bug 221012. Based on code review, enhance persistent directory | ||||||
|  |   policy. | ||||||
|  |  | ||||||
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ||||||
| Wed Jan  3 08:12:10 MST 2007 - jnorman@novell.com | Wed Jan  3 08:12:10 MST 2007 - jnorman@novell.com | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										43
									
								
								CASA/micasad/cache/SecretStore.cs
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										43
									
								
								CASA/micasad/cache/SecretStore.cs
									
									
									
									
										vendored
									
									
								
							| @@ -37,6 +37,11 @@ using sscs.crypto; | |||||||
|  |  | ||||||
| using Novell.CASA.CASAPolicy; | using Novell.CASA.CASAPolicy; | ||||||
|  |  | ||||||
|  | #if LINUX | ||||||
|  | using Mono.Unix.Native; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| namespace sscs.cache | namespace sscs.cache | ||||||
| { | { | ||||||
|     class SecretStore |     class SecretStore | ||||||
| @@ -1135,5 +1140,43 @@ namespace sscs.cache | |||||||
| 			Mono.Unix.Native.Syscall.umask(permissions); | 			Mono.Unix.Native.Syscall.umask(permissions); | ||||||
| #endif | #endif | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         internal bool IsDirectoryOwnedByUser(string sPath) | ||||||
|  |         { | ||||||
|  |  | ||||||
|  | #if LINUX | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 Stat stat = new Stat(); | ||||||
|  |                 int rcode = Syscall.stat(sPath, out stat); | ||||||
|  |  | ||||||
|  |                 if (stat.st_uid == (uint)this.user.UserIdentifier.GetUID()) | ||||||
|  |                 { | ||||||
|  |                     FilePermissions fp = stat.st_mode; | ||||||
|  |                     if ((fp & FilePermissions.S_IWUSR) != FilePermissions.S_IWUSR) | ||||||
|  |                     {                         | ||||||
|  |                         return false;                         | ||||||
|  |                     } | ||||||
|  |                     else | ||||||
|  |                     { | ||||||
|  |                         return true; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return false;                                         | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception e) | ||||||
|  |             { | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |              | ||||||
|  | #else | ||||||
|  |             return true; | ||||||
|  | #endif | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -277,9 +277,12 @@ namespace sscs.verbs | |||||||
| 				cpd.SetErrorMessage("Directory not allowed"); | 				cpd.SetErrorMessage("Directory not allowed"); | ||||||
| 				return wo;			 | 				return wo;			 | ||||||
| 			} | 			} | ||||||
| 	 |  | ||||||
| #endif | #endif | ||||||
|  |             if (!ssStore.IsDirectoryOwnedByUser(sNewDir)) | ||||||
|  |             { | ||||||
|  |                 cpd.SetErrorMessage("Directory not owned by user"); | ||||||
|  |                 return wo; | ||||||
|  |             } | ||||||
|  |  | ||||||
|             // copy all .miCASA* files to new location |             // copy all .miCASA* files to new location | ||||||
| 			string[] files = Directory.GetFiles(sOldDir, ".miCASA*"); | 			string[] files = Directory.GetFiles(sOldDir, ".miCASA*"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user