GitHub PullRequestReviewCommentEvent at 2014-02-28 12:35:22
Repository: macoslib
Actor: tempelmann
Payload: {"comment":{"url":"https://api.github.com/repos/macoslib/macoslib/pulls/comments/10162505","id":10162505,"diff_hunk":"@@ -0,0 +1,500 @@\n+#tag Window\n+Begin Window AuthorizationShellExample\n+   BackColor       =   16777215\n+   Backdrop        =   0\n+   BalloonHelp     =   \"\"\n+   CloseButton     =   True\n+   Composite       =   True\n+   Frame           =   0\n+   FullScreen      =   False\n+   HasBackColor    =   False\n+   Height          =   471\n+   ImplicitInstance=   True\n+   LiveResize      =   True\n+   MacProcID       =   0\n+   MaxHeight       =   32000\n+   MaximizeButton  =   True\n+   MaxWidth        =   32000\n+   MenuBar         =   593336822\n+   MenuBarVisible  =   True\n+   MinHeight       =   64\n+   MinimizeButton  =   True\n+   MinWidth        =   64\n+   Placement       =   0\n+   Resizeable      =   True\n+   Title           =   \"AuthorizationShell\"\n+   Visible         =   True\n+   Width           =   488\n+   Begin AuthorizationShell AuthorizationShell1\n+      Height          =   32\n+      Index           =   -2147483648\n+      Left            =   -43\n+      LockedInPosition=   False\n+      Scope           =   0\n+      TabPanelIndex   =   0\n+      Top             =   7\n+      Width           =   32\n+   End\n+   Begin PushButton runBut\n+      AutoDeactivate  =   True\n+      Bold            =   False\n+      ButtonStyle     =   0\n+      Cancel          =   False\n+      Caption         =   \"Run\"\n+      Default         =   True\n+      Enabled         =   True\n+      Height          =   20\n+      HelpTag         =   \"\"\n+      Index           =   -2147483648\n+      InitialParent   =   \"\"\n+      Italic          =   False\n+      Left            =   387\n+      LockBottom      =   False\n+      LockedInPosition=   False\n+      LockLeft        =   False\n+      LockRight       =   True\n+      LockTop         =   False\n+      Scope           =   0\n+      TabIndex        =   2\n+      TabPanelIndex   =   0\n+      TabStop         =   True\n+      TextFont        =   \"System\"\n+      TextSize        =   12\n+      TextUnit        =   0\n+      Top             =   46\n+      Underline       =   False\n+      Visible         =   True\n+      Width           =   81\n+   End\n+   Begin TextField cmdEdit\n+      AcceptTabs      =   \"\"\n+      Alignment       =   0\n+      AutoDeactivate  =   True\n+      AutomaticallyCheckSpelling=   False\n+      BackColor       =   16777215\n+      Bold            =   \"\"\n+      Border          =   True\n+      CueText         =   \"\"\n+      DataField       =   \"\"\n+      DataSource      =   \"\"\n+      Enabled         =   True\n+      Format          =   \"\"\n+      Height          =   22\n+      HelpTag         =   \"\"\n+      Index           =   -2147483648\n+      InitialParent   =   \"\"\n+      Italic          =   \"\"\n+      Left            =   75\n+      LimitText       =   0\n+      LockBottom      =   \"\"\n+      LockedInPosition=   False\n+      LockLeft        =   True\n+      LockRight       =   True\n+      LockTop         =   \"\"\n+      Mask            =   \"\"\n+      Password        =   \"\"\n+      ReadOnly        =   \"\"\n+      Scope           =   0\n+      TabIndex        =   0\n+      TabPanelIndex   =   0\n+      TabStop         =   True\n+      Text            =   \"/bin/sh\"\n+      TextColor       =   0\n+      TextFont        =   \"System\"\n+      TextSize        =   0\n+      TextUnit        =   0\n+      Top             =   17\n+      Underline       =   \"\"\n+      UseFocusRing    =   True\n+      Visible         =   True\n+      Width           =   299\n+   End\n+   Begin TextField argsEdit\n+      AcceptTabs      =   \"\"\n+      Alignment       =   0\n+      AutoDeactivate  =   True\n+      AutomaticallyCheckSpelling=   False\n+      BackColor       =   16777215\n+      Bold            =   \"\"\n+      Border          =   True\n+      CueText         =   \"\"\n+      DataField       =   \"\"\n+      DataSource      =   \"\"\n+      Enabled         =   True\n+      Format          =   \"\"\n+      Height          =   22\n+      HelpTag         =   \"\"\n+      Index           =   -2147483648\n+      InitialParent   =   \"\"\n+      Italic          =   \"\"\n+      Left            =   75\n+      LimitText       =   0\n+      LockBottom      =   \"\"\n+      LockedInPosition=   False\n+      LockLeft        =   True\n+      LockRight       =   True\n+      LockTop         =   \"\"\n+      Mask            =   \"\"\n+      Password        =   \"\"\n+      ReadOnly        =   \"\"\n+      Scope           =   0\n+      TabIndex        =   1\n+      TabPanelIndex   =   0\n+      TabStop         =   True\n+      Text            =   \"-i\"\n+      TextColor       =   0\n+      TextFont        =   \"System\"\n+      TextSize        =   0\n+      TextUnit        =   0\n+      Top             =   46\n+      Underline       =   \"\"\n+      UseFocusRing    =   True\n+      Visible         =   True\n+      Width           =   298\n+   End\n+   Begin TextField inputEdit\n+      AcceptTabs      =   \"\"\n+      Alignment       =   0\n+      AutoDeactivate  =   True\n+      AutomaticallyCheckSpelling=   False\n+      BackColor       =   16777215\n+      Bold            =   \"\"\n+      Border          =   True\n+      CueText         =   \"Enter a command here\"\n+      DataField       =   \"\"\n+      DataSource      =   \"\"\n+      Enabled         =   False\n+      Format          =   \"\"\n+      Height          =   22\n+      HelpTag         =   \"\"\n+      Index           =   -2147483648\n+      InitialParent   =   \"\"\n+      Italic          =   \"\"\n+      Left            =   20\n+      LimitText       =   0\n+      LockBottom      =   \"\"\n+      LockedInPosition=   False\n+      LockLeft        =   True\n+      LockRight       =   True\n+      LockTop         =   \"\"\n+      Mask            =   \"\"\n+      Password        =   \"\"\n+      ReadOnly        =   \"\"\n+      Scope           =   0\n+      TabIndex        =   3\n+      TabPanelIndex   =   0\n+      TabStop         =   True\n+      Text            =   \"\"\n+      TextColor       =   0\n+      TextFont        =   \"System\"\n+      TextSize        =   0\n+      TextUnit        =   0\n+      Top             =   103\n+      Underline       =   \"\"\n+      UseFocusRing    =   True\n+      Visible         =   True\n+      Width           =   449\n+   End\n+   Begin TextArea outputEdit\n+      AcceptTabs      =   \"\"\n+      Alignment       =   0\n+      AutoDeactivate  =   True\n+      AutomaticallyCheckSpelling=   False\n+      BackColor       =   16777215\n+      Bold            =   \"\"\n+      Border          =   True\n+      DataField       =   \"\"\n+      DataSource      =   \"\"\n+      Enabled         =   True\n+      Format          =   \"\"\n+      Height          =   288\n+      HelpTag         =   \"\"\n+      HideSelection   =   True\n+      Index           =   -2147483648\n+      InitialParent   =   \"\"\n+      Italic          =   \"\"\n+      Left            =   20\n+      LimitText       =   0\n+      LineHeight      =   0\n+      LineSpacing     =   1\n+      LockBottom      =   True\n+      LockedInPosition=   False\n+      LockLeft        =   True\n+      LockRight       =   True\n+      LockTop         =   True\n+      Mask            =   \"\"\n+      Multiline       =   True\n+      ReadOnly        =   True\n+      Scope           =   0\n+      ScrollbarHorizontal=   False\n+      ScrollbarVertical=   True\n+      Styled          =   \"\"\n+      TabIndex        =   4\n+      TabPanelIndex   =   0\n+      TabStop         =   True\n+      Text            =   \"Instructions:\\r\\rHit the Run button to run a new shell (sh) with root permissions.\\r\\rOnce you've entered your login credentials, reactivate this window by clicking into it.\\r\\rThen enter a command into the upper editfield, e.g.:\\r\\rls /.fseventsd\\r\\rYou'll get a listing of a folder that can't be read without root permissions.\\r\\rType 'exit' to close the session.\"\n+      TextColor       =   0\n+      TextFont        =   \"Courier\"\n+      TextSize        =   10\n+      TextUnit        =   0\n+      Top             =   137\n+      Underline       =   \"\"\n+      UseFocusRing    =   True\n+      Visible         =   True\n+      Width           =   449\n+   End\n+   Begin Label StaticText1\n+      AutoDeactivate  =   True\n+      Bold            =   \"\"\n+      DataField       =   \"\"\n+      DataSource      =   \"\"\n+      Enabled         =   True\n+      Height          =   20\n+      HelpTag         =   \"\"\n+      Index           =   -2147483648\n+      InitialParent   =   \"\"\n+      Italic          =   \"\"\n+      Left            =   19\n+      LockBottom      =   \"\"\n+      LockedInPosition=   False\n+      LockLeft        =   \"\"\n+      LockRight       =   \"\"\n+      LockTop         =   \"\"\n+      Multiline       =   \"\"\n+      Scope           =   0\n+      Selectable      =   False\n+      TabIndex        =   5\n+      TabPanelIndex   =   0\n+      Text            =   \"Cmd:\"\n+      TextAlign       =   2\n+      TextColor       =   0\n+      TextFont        =   \"System\"\n+      TextSize        =   0\n+      TextUnit        =   0\n+      Top             =   18\n+      Transparent     =   False\n+      Underline       =   \"\"\n+      Visible         =   True\n+      Width           =   51\n+   End\n+   Begin Label StaticText2\n+      AutoDeactivate  =   True\n+      Bold            =   \"\"\n+      DataField       =   \"\"\n+      DataSource      =   \"\"\n+      Enabled         =   True\n+      Height          =   20\n+      HelpTag         =   \"\"\n+      Index           =   -2147483648\n+      InitialParent   =   \"\"\n+      Italic          =   \"\"\n+      Left            =   19\n+      LockBottom      =   \"\"\n+      LockedInPosition=   False\n+      LockLeft        =   \"\"\n+      LockRight       =   \"\"\n+      LockTop         =   \"\"\n+      Multiline       =   \"\"\n+      Scope           =   0\n+      Selectable      =   False\n+      TabIndex        =   6\n+      TabPanelIndex   =   0\n+      Text            =   \"Args:\"\n+      TextAlign       =   2\n+      TextColor       =   0\n+      TextFont        =   \"System\"\n+      TextSize        =   0\n+      TextUnit        =   0\n+      Top             =   47\n+      Transparent     =   False\n+      Underline       =   \"\"\n+      Visible         =   True\n+      Width           =   51\n+   End\n+   Begin Line Line1\n+      BorderWidth     =   1\n+      Height          =   50\n+      Index           =   -2147483648\n+      InitialParent   =   \"\"\n+      Left            =   13\n+      LineColor       =   11842740\n+      LockedInPosition=   False\n+      Scope           =   0\n+      TabPanelIndex   =   0\n+      Top             =   83\n+      Visible         =   True\n+      Width           =   100\n+      X1              =   13\n+      X2              =   475\n+      Y1              =   83\n+      Y2              =   83\n+   End\n+   Begin PushButton clearOutputBut\n+      AutoDeactivate  =   True\n+      Bold            =   \"\"\n+      ButtonStyle     =   0\n+      Cancel          =   \"\"\n+      Caption         =   \"Clear\"\n+      Default         =   \"\"\n+      Enabled         =   True\n+      Height          =   20\n+      HelpTag         =   \"\"\n+      Index           =   -2147483648\n+      InitialParent   =   \"\"\n+      Italic          =   \"\"\n+      Left            =   387\n+      LockBottom      =   True\n+      LockedInPosition=   False\n+      LockLeft        =   False\n+      LockRight       =   True\n+      LockTop         =   False\n+      Scope           =   0\n+      TabIndex        =   7\n+      TabPanelIndex   =   0\n+      TabStop         =   True\n+      TextFont        =   \"System\"\n+      TextSize        =   0\n+      TextUnit        =   0\n+      Top             =   437\n+      Underline       =   \"\"\n+      Visible         =   True\n+      Width           =   80\n+   End\n+End\n+#tag EndWindow\n+\n+#tag WindowCode\n+\t#tag Event\n+\t\tSub Close()\n+\t\t  AuthorizationShell1.Close\n+\t\t  \n+\t\tEnd Sub\n+\t#tag EndEvent\n+\n+\n+\t#tag Method, Flags = &h0\n+\t\tSub BringSelfToFront()\n+\t\t  // This is a little hack to keep this program's window active after launching the interactive shell.\n+\t\t  // I (TT) can't even explain why it works.\n+\t\t  \n+\t\t  declare function GetCurrentProcess lib \"Carbon\" (ByRef psn as UInt64) as Integer\n+\t\t  declare function GetFrontProcess lib \"Carbon\" (ByRef psn as UInt64) as Integer\n+\t\t  declare function SetFrontProcess lib \"Carbon\" (ByRef psn as UInt64) as Integer\n+\t\t  \n+\t\t  dim psn, psn2 as UInt64\n+\t\t  call GetFrontProcess (psn2)\n+\t\t  call SetFrontProcess (psn2) ' this one is important\n+\t\t  call GetCurrentProcess (psn)\n+\t\t  call SetFrontProcess (psn)\n+\t\tEnd Sub\n+\t#tag EndMethod\n+\n+\n+#tag EndWindowCode\n+\n+#tag Events AuthorizationShell1\n+\t#tag Event\n+\t\tSub Completed()\n+\t\t  // This event gets invoked when the shell is terminated\n+\t\t  // (e.g. by entering \"exit\" in the \"sh\" shell).\n+\t\t  \n+\t\t  inputEdit.Enabled = false\n+\t\t  runBut.Enabled = true\n+\t\t  cmdEdit.Enabled = true\n+\t\t  argsEdit.Enabled = true\n+\t\t  cmdEdit.SetFocus\n+\t\t  \n+\t\tEnd Sub\n+\t#tag EndEvent\n+\t#tag Event\n+\t\tSub DataAvailable()\n+\t\t  // This event gets invoked through the call of the Poll method\n+\t\t  \n+\t\t  outputEdit.AppendText me.ReadAll\n+\t\t  outputEdit.ScrollPosition = Len(outputEdit.Text) ' scroll to the end\n+\t\tEnd Sub\n+\t#tag EndEvent\n+#tag EndEvents\n+#tag Events runBut\n+\t#tag Event\n+\t\tSub Action()\n+\t\t  dim cmd, args() as String\n+\t\t  \n+\t\t  cmd = cmdEdit.Text\n+\t\t  args = argsEdit.Text.Split (\" \")\n+\t\t  \n+\t\t  runBut.Enabled = false\n+\t\t  \n+\t\t  if Keyboard.OptionKey then\n+\t\t    // If option key is held down when the Run button is pressed,\n+\t\t    // let's preset username and password (these should be read\n+\t\t    // from the Keychain, ideally).\n+\t\t    dim username as String = \"user name goes here\"\n+\t\t    dim password as String = \"password goes here\"","path":"Examples/AuthorizationShellExample.rbfrm","position":433,"original_position":433,"commit_id":"9a54dce70b0e0c9839f0ee66f531fa29074183be","original_commit_id":"9a54dce70b0e0c9839f0ee66f531fa29074183be","user":{"login":"tempelmann","id":461920,"avatar_url":"https://avatars.githubusercontent.com/u/461920","gravatar_id":"2d95320d92a00edaf56df3ab7dcc1017","url":"https://api.github.com/users/tempelmann","html_url":"https://github.com/tempelmann","followers_url":"https://api.github.com/users/tempelmann/followers","following_url":"https://api.github.com/users/tempelmann/following{/other_user}","gists_url":"https://api.github.com/users/tempelmann/gists{/gist_id}","starred_url":"https://api.github.com/users/tempelmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tempelmann/subscriptions","organizations_url":"https://api.github.com/users/tempelmann/orgs","repos_url":"https://api.github.com/users/tempelmann/repos","events_url":"https://api.github.com/users/tempelmann/events{/privacy}","received_events_url":"https://api.github.com/users/tempelmann/received_events","type":"User","site_admin":false},"body":"I think it's a very bad idea to suggest having passwords hard-coded in code. Even if some people may understand that this is not right, there are enough beginner who will just do this as shown.\r\nDidn't my example I sent you include Keychain access? If not, let me send some sample for about this to you if you have the time to update this code for it, please?","created_at":"2014-02-28T12:35:22Z","updated_at":"2014-02-28T12:35:22Z","html_url":"https://github.com/macoslib/macoslib/pull/136#discussion_r10162505","pull_request_url":"https://api.github.com/repos/macoslib/macoslib/pulls/136","_links":{"self":{"href":"https://api.github.com/repos/macoslib/macoslib/pulls/comments/10162505"},"html":{"href":"https://github.com/macoslib/macoslib/pull/136#discussion_r10162505"},"pull_request":{"href":"https://api.github.com/repos/macoslib/macoslib/pulls/136"}}}}