The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,862 other subscribers

Mikrotik Router OS 6.37.1 – scripts and schedules – what policies they need to run

Posted by jpluimers on 2017/10/19

minimum schedule and script policies: read/write/policy/test

minimum schedule and script policies: read/write/policy/test

A year later, Mikrotik still needs to update their documentation, so from my question at [WayBack[Mikrotik follow-up needed] Router OS 6.37.1 – scheduled script cannot execute script – MikroTik RouterOS.

TL;DR:

  • use the same policies for scripts and schedules
  • use these policies as a minimum for scripts and schedules:
    • read
    • write
    • policy
    • test

Forum post:

I found out two things:

  1. the testFunctionScript needs at least these policies to call a function: read, write, policy, test
  2. a schedule needs at least the same permissions as a script in order to run the script at all

This is how the various permissions affect the testFunctionScript script:

  • no policies only allow :log info "testFunctionScript"; .
  • read allows the above and :local testFunctionJobs [/system script job print as-value detail]; which then is be logged with :log info "testFunctionJobs=$testFunctionJobs";
  • only write seems equivalent to no policies as it will only allow :log info "testFunctionScript";
  • read and write is equivalent to read
  • a lone policy or test policy (talk about confusion!) do not add functionality, so any combinations of just policy or testwith read and/or write get the same functionality as above
  • policy and test without any other seem equivalent to no policies as they result in only :log info "testFunctionScript"; to execute
  • the combined policies read, write, policy, test allow full script functionality including the function call and using the function call result

The above findings show that more logging is needed: the scheduler should log when (and why!) it does not have enough permissions to run a script. Right now you’re in the dark on when (and why!) a script isn’t ran by the scheduler.

The above findings show that these parts of the documentation need updating:

http://wiki.mikrotik.com/wiki/Manual:Sc … repository (update with info about the above policy combinations)
http://wiki.mikrotik.com/wiki/Manual:Ro … Properties (update with info about the above policy combinations)
http://wiki.mikrotik.com/wiki/Manual:System/Scheduler (does not document anything about policies at all)

The various scripts (apply your mix of policies that you need)

## logon as user jeroenp

/system script environment remove [ /system script environment find where name="testFunction" ];
:global testFunction do={
  :local result [/system resource get uptime];
  :return $result;
}

/system script environment print detail where name=testFunction
# 0 name="testFunction" value=";(eval /system scheduler  (eval /localname=$result;value=(eval (eval /system resource getvalue-name=uptime))) (eval /returnvalue=$result))" 

:log info "direct execution of testFunction"

{
:global testFunction;
:local testFunctionType [:typeof testFunction];
:local testFunctionResult [$testFunction];
:log info "testFunctionScript";
:log info "testFunctionType=$testFunctionType";
:log info "testFunctionResult=$testFunctionResult";
:log info "testFunction=$testFunction";
}

/log print where buffer=memory && (message~"testFunction" || topics~"info")

/system script remove [ /system script find where name="testFunctionScript" ];
/system script add name=testFunctionScript owner=jeroenp policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":global testFunction;\r\
    \n:log info \"testFunctionScript\";\r\
    \n:local testFunctionType [:typeof testFunction];\r\
    \n:local testFunctionResult [\$testFunction];\r\
    \n:log info \"testFunctionType=\$testFunctionType\";\r\
    \n:log info \"testFunctionResult=\$testFunctionResult\";\r\
    \n:log info \"testFunction=\$testFunction\";\r\
    \n"

:log info "execution of testFunction via testFunctionScript"

/system script run testFunctionScript

/log print where buffer=memory && (message~"testFunction" || topics~"info")

/system scheduler remove [ /system scheduler find where name="testFunctionScriptSchedule" ];
/system scheduler add interval=10s name=testFunctionScriptSchedule on-event=testFunctionScript policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=sep/22/2015 start-time=12:02:37

:log info "execution of testFunction via testFunctionScriptSchedule calling testFunctionScript"
:delay 20s
/system scheduler disable testFunctionScriptSchedule

/log print where buffer=memory && (message~"testFunction" || topics~"info")

/system scheduler print detail where name="testFunctionScriptSchedule"

–jeroen

Posted in Development, Internet, MikroTik, Power User, RouterOS, routers, Scripting, Software Development | Leave a Comment »

delphi – VCL events with anonymous methods – what do you think about this implementation? – Stack Overflow

Posted by jpluimers on 2017/10/19

A long time ago, Pablo Vizcay a.k.a. [WayBackpragmatic_programmer wrote some cool code at [WayBackdelphi – VCL events with anonymous methods – what do you think about this implementation? – Stack Overflow.

I still think it’s a very neat solution to bind method references to events.

type
  TNotifyEventDispatcher = class(TComponent)
  protected
    FClosure: TProc<TObject>;

    procedure OnNotifyEvent(Sender: TObject);
  public
    class function Create(Owner: TComponent; Closure: TProc<TObject>): TNotifyEvent; overload;

    function Attach(Closure: TProc<TObject>): TNotifyEvent;
  end;

implementation

class function TNotifyEventDispatcher.Create(Owner: TComponent; Closure: TProc<TObject>): TNotifyEvent;
begin
  Result := TNotifyEventDispatcher.Create(Owner).Attach(Closure)
end;

function TNotifyEventDispatcher.Attach(Closure: TProc<TObject>): TNotifyEvent;
begin
  FClosure := Closure;
  Result := Self.OnNotifyEvent
end;

procedure TNotifyEventDispatcher.OnNotifyEvent(Sender: TObject);
begin
  if Assigned(FClosure) then
    FClosure(Sender)
end;

end.

And this is how it’s used for example:

procedure TForm1.FormCreate(Sender: TObject);
begin    
  Button1.OnClick := TNotifyEventDispatcher.Create(Self,
    procedure (Sender: TObject)
    begin
      Self.Caption := 'DONE!'
    end)
end;

–jeroen

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 1 Comment »

Kristian Köhntopp – Google+

Posted by jpluimers on 2017/10/18

[WayBack] Kristian Köhntopp – Google+:

The S in IoT is for Security, and the U is for Update Policy.
 –jeroen

 

Posted in Development, Fun, Power User, Quotes, Software Development, WiFi | Leave a Comment »

The Software Development Process – Science, Engineering, Art, or Craft? – CodeProject

Posted by jpluimers on 2017/10/18

On the long-read list: [WayBackThe Software Development Process – Science, Engineering, Art, or Craft? – CodeProject

 

Posted in Agile, Development, Software Development | Leave a Comment »

GitHub – sinbad/spriterecolour: Sprite processor to allow dynamic recolouring

Posted by jpluimers on 2017/10/18

One day this will be extremely useful to me: [WayBackGitHub – sinbad/spriterecolour: Sprite processor to allow dynamic recolouring

Via: [WayBackSpriteRecolour, an open source sprite recolouring tool · SteveStreeting.com

TL;DR:

Read the rest of this entry »

Posted in Algorithms, Development, Software Development | Leave a Comment »

Google’s AI can create better machine-learning code than the researchers who made it

Posted by jpluimers on 2017/10/17

[WayBack] Google’s AI can create better machine-learning code than the researchers who made it:

Google’s AutoML project has yielded significant advances in the ability for machine-learning systems to replicate and improve AI code.

Via:

–jeroen

Posted in AI and ML; Artificial Intelligence & Machine Learning, Development, LifeHacker, Power User, science, Software Development | Leave a Comment »

Why Delphi users love @TMSsoftwareNews: bugfix within 2.5 hours.

Posted by jpluimers on 2017/10/17

People love @TMSSoftwareNews because of the short bug-fix turnaround. In this case 2.5 hours: [WayBack@jpluimers: @TMSsoftwareNews when entering a perfectly valid email address like word.word+tag.subtag@gmail.com: Please enter a valid Email Address.

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, Software Development | Leave a Comment »

UPS PIco HV3.0 documentation not on github: “03_0x38_W_UPS PIco HV3.0.pdf”

Posted by jpluimers on 2017/10/17

I ordered a UPS PIco HV3.0 A Stack 450 Plus and it arrived without any documentation on how to solder the parts together.

So I tried searching for them: https://www.google.com/search?q=UPS+PIco+HV3.0+A+Stack+450+Plus+installation+instructions which turned mostly github based URLs.

I learned there is a bit on github:

But despite code and documentation being there, no installation instructions on how to solder the stuff together.

Luckily, they responded quickly to my tweet So I got my “UPS PIco HV3.0 A Stack 450 Plus” @ModMyPi but no assembly instructions. Where do all the non-soldered parts go when using RPi3? and a quick respons thread revealing I needed 03_0x38_W_UPS PIco HV3.0.pdf which – TADAAAA – is on Google drive and on the forums at [WayBackUPS PIco Firmware Update & Troubleshooting : Technical Support

So despite github providing an excellent platform for discussion and storing documentation, something archaic like a forum is used to store data in a disorganised way.

Too bad, as the document itself is 100+ page of invaluable documentation.

So in case of future bit-rot, here are the links:

Read the rest of this entry »

Posted in Development, Hardware Development, Hardware Interfacing, Raspberry Pi | Leave a Comment »

TEncryptedIniFile: easy to use class for handling app settings with encryption in Delphi – TMS Software Blog

Posted by jpluimers on 2017/10/17

[WayBackTMS Software | Blog | TEncryptedIniFile: easy to use class for handling app settings with encryption

via: [WayBackA new blog has been posted:TEncryptedIniFile: easy to use class for handling app settings with encryption – Michael Thuma – Google+

I wonder how that works with encryption algorithms based on thin Delphi wrappers around proven open source encryption libraries.

–jeroen

PS: Note the G+ link died. Not sure why, but that’s why I archived the original as a WayBack link when writing this post.

Posted in Delphi, Development, Software Development | 4 Comments »

OnePlus OxygenOS built-in analytics: disable it as soon as you can

Posted by jpluimers on 2017/10/16

Remove the OnePlus Analytics service because of privacy violations:

Source: [WayBackOnePlus OxygenOS built-in analytics

We take a look at the analytics built into the OxygenOS, the flavour of Android built by phone manufacturer OnePlus.

The analytics data is sent over https, but it contains way too much information on your privacy.

This also taught me about this interesting project: [WayBack] OWASP Zed Attack Proxy Project – OWASP

These tweets describe how to disabled it:

It was also present OnePlus Five, I found it through:

  1. Settings
  2. Developer Options
  3. Running Services
  4. OnePlus System Service
  5. OnePlusAnalyticsJobService

Until removed, it restarts at every boot.

Removing the service seems more permanent than the alternative [WayBack] Dear OnePlus, please stop spying on my phone:

  1. Settings
  2. Advanced
  3. Join user experience program
  4. toggle this option to off

It is unclear to me what turned that option on in the first place.

–jeroen

via: [WayBack] Welp. As a OnePlus owner, this makes me pretty damn unhappy :/ https://www.chrisdcmoore.co.uk/post/oneplus-analytics/ +Colm Buckley – Kristian Köhntopp – Google+

 

Posted in Android Devices, OnePlus Five, OnePlus Two, Power User, Privacy | Leave a Comment »