How to enable Server Port 102 (ISOonTCP).
Is blocked from System...
[Done] Server with Port 102 need admin rights
[Done] Server with Port 102 need admin rights
Last edited by mk-soft on Wed Nov 07, 2018 1:39 pm, edited 2 times in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Server Port 102
OSX and Linux need root right to use network ports in the lower area.
So start my now program with admin right...
Link -> Run program with sudo privileg: viewtopic.php?f=19&t=68678
So start my now program with admin right...
Code: Select all
AuthorizationExecuteWithPrivileges(...)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Server Port 102
Her now the module "RunAsAdmin"
Code: Select all
;-TOP
; Comment : Module RunAsAdmin
; Author : mk-soft
; Version : v1.01
; Date : 07.11.2018
; OS : OSX
; Thanks to:
; - Airr
; - Wolfram
EnableExplicit
; ***************************************************************************************
;- Begin Module RunAsAdmin
DeclareModule RunAsAdmin
Declare Login()
EndDeclareModule
; ---
Module RunAsAdmin
; -----------------------------------------------------------------------------------
; Error codes returned by Authorization API.
Enumeration AuthorizationResult
#errAuthorizationSuccess = 0 ;/* The authorization was successful. */
#errAuthorizationInvalidSet = -60001 ;/* The authorization rights are invalid. */
#errAuthorizationInvalidRef = -60002 ;/* The authorization reference is invalid. */
#errAuthorizationInvalidTag = -60003 ;/* The authorization tag is invalid. */
#errAuthorizationInvalidPointer = -60004 ;/* The returned authorization is invalid. */
#errAuthorizationDenied = -60005 ;/* The authorization was denied. */
#errAuthorizationCanceled = -60006 ;/* The authorization was cancelled by the user. */
#errAuthorizationInteractionNotAllowed = -60007 ;/* The authorization was denied since no user interaction was possible. */
#errAuthorizationInternal = -60008 ;/* Unable To obtain authorization For this operation. */
#errAuthorizationExternalizeNotAllowed = -60009 ;/* The authorization is Not allowed To be converted To an external format. */
#errAuthorizationInternalizeNotAllowed = -60010 ;/* The authorization is Not allowed To be created from an external format. */
#errAuthorizationInvalidFlags = -60011 ;/* The provided option flag(s) are invalid For this authorization operation. */
#errAuthorizationToolExecuteFailure = -60031 ;/* The specified program could Not be executed. */
#errAuthorizationToolEnvironmenterror = -60032 ;/* An invalid status was returned during execution of a privileged tool. */
#errAuthorizationBadAddress = -60033 ;/* The requested socket address is invalid (must be 0-1023 inclusive). */
EndEnumeration
; Authorization
#kAuthorizationEmptyEnvironment = #Null
#kAuthorizationRightExecute = 0 ; UTF8("system.privilege.admin")
#kAuthorizationFlagDefaults = 0
#kAuthorizationFlagInteractionAllowed = (1 << 0)
#kAuthorizationFlagPreAuthorize = (1 << 4)
#kAuthorizationFlagExtendRights = (1 << 1)
; -----------------------------------------------------------------------------------
; Structures
Structure AuthorizationItem
*name ;A zero-terminated string in UTF-8 encoding.
valueLength.i
*value
flags.i
EndStructure
Structure AuthorizationRights
AuthorizationItemSet.i
*AuthorizationRights
EndStructure
Structure CMD
*parameter1
*parameter2
*parameter3
*parameter4
*parameter5
*parameter6
*parameter7
*parameter8
cmd_terminator.i
EndStructure
ImportC "/System/Library/Frameworks/Security.framework/Security"
AuthorizationCreate(rights, environment, flags, *AuthorizationRef)
AuthorizationExecuteWithPrivileges(AuthorizationRef, cmd, flags, *arguments, file_ptr)
AuthorizationFree(authRef, flags)
AuthorizationCopyRights(authorization, *rights, *environment, flags.l, *authorizedRights)
EndImport
; -----------------------------------------------------------------------------------
Procedure _Login()
Protected authorizationRef.i, status.i, flags.i, *tool, result.i
Protected right.AuthorizationItem
Protected rights.AuthorizationRights
Protected ArgList.CMD
status = AuthorizationCreate(#Null, #kAuthorizationEmptyEnvironment, #kAuthorizationFlagDefaults, @authorizationRef)
If status <> #errAuthorizationSuccess
MessageRequester("Error", "Creating Initial Authorization: Errorcode " + Str(status), #PB_MessageRequester_Error)
Else
right\name = UTF8("system.privilege.admin")
rights\AuthorizationItemSet = 1
rights\AuthorizationRights = @right
flags = #kAuthorizationFlagDefaults | #kAuthorizationFlagInteractionAllowed | #kAuthorizationFlagPreAuthorize | #kAuthorizationFlagExtendRights
status = AuthorizationCopyRights(authorizationRef, @rights, #Null, flags, #Null);
If status <> #errAuthorizationSuccess
MessageRequester("Error", "Copy Authorization Rights: Errorcode " + Str(status), #PB_MessageRequester_Error)
End
EndIf
EndIf
*tool = UTF8(ProgramFilename())
ArgList\parameter1 = UTF8("1")
status = AuthorizationExecuteWithPrivileges(authorizationRef, *tool, #kAuthorizationFlagDefaults, @ArgList, #Null);
If status <> #errAuthorizationSuccess
MessageRequester("Error", "Execute With Privileges: Errorcode " + Str(status))
EndIf
End
EndProcedure
; -----------------------------------------------------------------------------------
Procedure Login()
If CountProgramParameters() = 0
_Login()
Else
ProcedureReturn #True
EndIf
EndProcedure
; -----------------------------------------------------------------------------------
EndModule
;- Begin Module RunAsAdmin
; ***************************************************************************************
CompilerIf #PB_Compiler_IsMainFile
;IncludeFile "snap7_server_mac.pb"
If RunAsAdmin::Login()
MessageRequester("Info", "Program run as admin!", #PB_MessageRequester_Info)
;Main()
EndIf
CompilerEndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: [Done] Server with Port 102 need admin rights
Hi Mk-soft,
Do you have an updated module it doesn't work on Monterey 12.6.1
I'm trying to get dnscope running on localhost port 53 and it won't start so I assume it needs root.
Do you have an updated module it doesn't work on Monterey 12.6.1
I'm trying to get dnscope running on localhost port 53 and it won't start so I assume it needs root.
Re: [Done] Server with Port 102 need admin rights
I'll watch it at home tonight. Here I have only High Sierra running.
Maybe it is enough to adjust the import, since the paths have changed.
Link: Module RunAsAdmin
Maybe it is enough to adjust the import, since the paths have changed.
Link: Module RunAsAdmin
Code: Select all
; Update link
Last edited by mk-soft on Tue Nov 08, 2022 9:24 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive