comparison common/util.c @ 1010:1c1964c27b39 runafterinstall

(issue54) commit work in progress on start after installation
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 02 Sep 2014 14:25:40 +0200
parents 427e2e18b8c8
children fd85a02d771d
comparison
equal deleted inserted replaced
1004:7dff5c0c569c 1010:1c1964c27b39
14 #include <sys/types.h> 14 #include <sys/types.h>
15 #include <pwd.h> 15 #include <pwd.h>
16 #include <grp.h> 16 #include <grp.h>
17 #include <string.h> 17 #include <string.h>
18 #else 18 #else
19 #include <winsafer.h>
19 #include <windows.h> 20 #include <windows.h>
20 #include <accctrl.h> 21 #include <accctrl.h>
21 #include <aclapi.h> 22 #include <aclapi.h>
22 #include <shlobj.h> 23 #include <shlobj.h>
23 #endif 24 #endif
722 LocalFree(descriptor); 723 LocalFree(descriptor);
723 724
724 return retval; 725 return retval;
725 } 726 }
726 #endif 727 #endif
728
729 #ifdef WIN32
730 /** @brief get a restricted access token
731 *
732 * This function uses the Software Restriction API to obtain the
733 * access token for a process run als normal user.
734 *
735 * @returns A restricted handle or NULL on error.
736 */
737 HANDLE
738 get_restricted_token()
739 {
740 SAFER_LEVEL_HANDLE user_level = NULL;
741 HANDLE retval = NULL;
742 if (!SaferCreateLevel(SAFER_SCOPEID_USER,
743 SAFER_LEVELID_NORMALUSER,
744 SAFER_LEVEL_OPEN, &user_level, NULL))
745 {
746 PRINTLASTERROR ("Failed to create user level.\n");
747 return NULL;
748 }
749
750 if (!SaferComputeTokenFromLevel(user_level, NULL, &retval, 0, NULL))
751 {
752 SaferCloseLevel(user_level);
753 return NULL;
754 }
755
756 return retval;
757 }
758
759 HANDLE
760 get_normal_token()
761 {
762 SAFER_LEVEL_HANDLE user_level = NULL;
763 HANDLE retval = NULL;
764 if (!SaferCreateLevel(SAFER_SCOPEID_USER,
765 SAFER_LEVELID_NORMALUSER,
766 SAFER_LEVEL_OPEN, &user_level, NULL))
767 {
768 PRINTLASTERROR ("Failed to create user level.\n");
769 return NULL;
770 }
771
772 if (!SaferComputeTokenFromLevel(user_level, NULL, &retval, 0, NULL))
773 {
774 SaferCloseLevel(user_level);
775 return NULL;
776 }
777
778 return retval;
779 }
780 #endif

http://wald.intevation.org/projects/trustbridge/