Bladeren bron

Fixed Linux home dir extraction.

Brucey 5 jaren geleden
bovenliggende
commit
bac743a839
7 gewijzigde bestanden met toevoegingen van 28 en 34 verwijderingen
  1. 16 3
      volumes.mod/linuxglue.c
  2. 1 1
      volumes.mod/macglue.c
  3. 1 1
      volumes.mod/main.bmx
  4. 3 24
      volumes.mod/vol_linux.bmx
  5. 1 1
      volumes.mod/vol_mac.bmx
  6. 1 1
      volumes.mod/vol_win.bmx
  7. 5 3
      volumes.mod/volumes.bmx

+ 16 - 3
volumes.mod/linuxglue.c

@@ -1,8 +1,6 @@
 /*
-  This file is not licenced under the GPL like the rest of the code.
-  Its is under the MIT license, to encourage reuse by cut-and-paste.
-
   Copyright (c) 2007 Red Hat, inc
+  Copyright (c) 2010-2020 Bruce A Henderson
 
   Permission is hereby granted, free of charge, to any person
   obtaining a copy of this software and associated documentation files
@@ -260,4 +258,19 @@ int bmx_volumes_volspace_refresh(BBString * vol, BBInt64 * _size, BBInt64 * _fre
 	return res;
 }
 
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
+
+BBString * bmx_volumes_gethome() {
 
+	BBString * res = &bbEmptyString;
+
+	struct passwd * pwd = getpwuid(getuid());
+	
+	if (pwd != NULL) {
+		res = bbStringFromUTF8String(pwd->pw_dir);
+	}
+	
+	return res;
+}

+ 1 - 1
volumes.mod/macglue.c

@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2006-2019 Bruce A Henderson
+  Copyright (c) 2006-2020 Bruce A Henderson
  
   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal

+ 1 - 1
volumes.mod/main.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2007-2019 Bruce A Henderson
+' Copyright (c) 2007-2020 Bruce A Henderson
 ' 
 ' Permission is hereby granted, free of charge, to any person obtaining a copy
 ' of this software and associated documentation files (the "Software"), to deal

+ 3 - 24
volumes.mod/vol_linux.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2007-2019 Bruce A Henderson
+' Copyright (c) 2007-2020 Bruce A Henderson
 ' 
 ' Permission is hereby granted, free of charge, to any person obtaining a copy
 ' of this software and associated documentation files (the "Software"), to deal
@@ -32,11 +32,9 @@ Extern
 	Function _endmntent:Int(file:Int) = "endmntent"
 	Function _statvfs:Int(path:Byte Ptr, stat:Byte Ptr) = "statvfs"
 	
-	Function _getuid:Int() = "getuid"
-	Function _getpwuid:Byte Ptr(uid:Int) = "getpwuid"
-	
 	Function bmx_userdirlookup:String(dirType:String)
 	Function bmx_volumes_volspace_refresh:Int(vol:String, _size:Long Ptr, _free:Long Ptr)
+	Function bmx_volumes_gethome:String()
 End Extern
 
 Type Tmntent
@@ -62,17 +60,6 @@ Type Tstatvfs
 	Field f_namemax:Int  ' maximum filename length 
 End Type
 
-Type TPasswdEntry
-	Field pw_name:Byte Ptr		' user name 
-	Field pw_passwd:Byte Ptr	' user password 
-	Field pw_uid:Int			' user id 
-	Field pw_gid:Int			' group id 
-	Field pw_gecos:Byte Ptr	' real name 
-	Field pw_dir:Byte Ptr		' home directory 
-	Field pw_shell:Byte Ptr	' shell program 
-End Type
-
-
 Global linuxVolume_driver:TLinuxVolumeDriver = New TLinuxVolumeDriver
 
 Type TLinuxVolumeDriver
@@ -199,16 +186,8 @@ Type TLinuxVolume Extends TVolume
 		If Not dir Or dir.length = 0 Then
 			' work it out ourselves...
 			
-			Local pwdptr:Byte Ptr = _getpwuid(_getuid())
-			
-			If pwdptr Then
-			
-				Local pwd:TPasswdEntry = New TPasswdEntry
-				MemCopy pwd, pwdptr, Size_T(SizeOf pwd)
+			dir = bmx_volumes_gethome()
 
-				dir = String.FromUTF8String(pwd.pw_dir)
-			
-			End If
 		End If
 		
 		Return dir

+ 1 - 1
volumes.mod/vol_mac.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2007-2019 Bruce A Henderson
+' Copyright (c) 2007-2020 Bruce A Henderson
 ' 
 ' Permission is hereby granted, free of charge, to any person obtaining a copy
 ' of this software and associated documentation files (the "Software"), to deal

+ 1 - 1
volumes.mod/vol_win.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2007-2019 Bruce A Henderson
+' Copyright (c) 2007-2020 Bruce A Henderson
 ' 
 ' Permission is hereby granted, free of charge, to any person obtaining a copy
 ' of this software and associated documentation files (the "Software"), to deal

+ 5 - 3
volumes.mod/volumes.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2006-2019 Bruce A Henderson
+' Copyright (c) 2006-2020 Bruce A Henderson
 ' 
 ' Permission is hereby granted, free of charge, to any person obtaining a copy
 ' of this software and associated documentation files (the "Software"), to deal
@@ -25,11 +25,13 @@ bbdoc: Volumes
 End Rem
 Module BRL.Volumes
 
-ModuleInfo "Version: 1.10"
+ModuleInfo "Version: 1.11"
 ModuleInfo "License: MIT"
 ModuleInfo "Author: Bruce A Henderson"
-ModuleInfo "Copyright: (c) 2006-2019 Bruce A Henderson"
+ModuleInfo "Copyright: (c) 2006-2020 Bruce A Henderson"
 
+ModuleInfo "History: 1.11"
+ModuleInfo "History: Fixed Linux home dir extraction."
 ModuleInfo "History: 1.10"
 ModuleInfo "History: Updated for NG."
 ModuleInfo "History: Reworked Mac statfs handling."