It is currently Mon Nov 19, 2018 12:57 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [Done] Server with Port 102 need admin rights
PostPosted: Tue Nov 06, 2018 11:32 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1444
Location: Germany
How to enable Server Port 102 (ISOonTCP).
Is blocked from System...

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Last edited by mk-soft on Wed Nov 07, 2018 1:39 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Server Port 102
PostPosted: Wed Nov 07, 2018 12:16 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1444
Location: Germany
OSX and Linux need root right to use network ports in the lower area.

So start my now program with admin right...

Code:
AuthorizationExecuteWithPrivileges(...)


Link -> Run program with sudo privileg: viewtopic.php?f=19&t=68678

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: Server Port 102
PostPosted: Wed Nov 07, 2018 1:35 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1444
Location: Germany
Her now the module "RunAsAdmin" :wink:
Code:
;-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 OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye