[squeak-dev] Can a running Squeak program look at a Squeak image file and know if it is a good image?

Louis LaBrunda Lou at Keystone-Software.com
Tue Jul 25 20:21:33 UTC 2017


Hi Bert,

Thanks for the help.  I control the image.  I would make a new version available.

The program runs headless on a Raspberry Pi.  The user interfaces with it via a web browser.
The system is a Seaside program that allows the user to control the GPIO pins from a web
browser.  Normally there wouldn't be a mouse or keyboard.  The user wouldn't know where to put
a new copy of the program.

The program would allow the user to do a file upload.  I want to make a small number of checks
of the new uploaded program before replacing the existing image.  I want to protect the user
from dumb mistakes like pointing the file upload to the wrong file.  If the user points to a
Squeak image that isn't the real program, they are on their own.  That can be fixed but the
program would no longer be able to help.

I don't know if a checksum would work as I don't know what the current program would be able to
compare the checksum to.  Unless I were able to append it to the end of the file or something
like that.

Thanks again for any ideas.

Lou

On Tue, 25 Jul 2017 21:31:00 +0200, Bert Freudenberg <bert at freudenbergs.de> wrote:

>We don't have a meaningful "diff" between images. You could compare the
>list of package versions etc. but it's not foolproof as there might be
>modifications outside the packages.
>
>Maybe it would help if you gave us a broader picture - are you just trying
>to update an application with a new image? That is, do you control what the
>new image is, or are users supposed to upload their own / arbitrary images?
>
>If you control the image then I would simply do a checksum and verify that
>before replacing.
>
>- Bert -
>
>On Tue, Jul 25, 2017 at 9:24 PM, Louis LaBrunda <Lou at keystone-software.com>
>wrote:
>
>> Thanks Dave, I got it now.  Don't beat yourself up, I appreciate the help
>> even if it is slow in
>> coming.  After all, beggars can't be choosers.  Hopefully one last
>> question.  Is there some
>> method or methods, I can send the running image and the image file that
>> allow me to conclude
>> they are close in nature?
>>
>> Lou
>>
>>
>> On Tue, 25 Jul 2017 15:06:49 -0400 (EDT), "David T. Lewis" <
>> lewis at mail.msen.com> wrote:
>>
>> >Lou,
>> >
>> >So sorry, I think I need a new brain today. The repository is on
>> >source.squeak.org, not on squeaksource.com as I said in my earlier mail.
>> >The stuff on squeaksource.com is ancient, and all recent VM related work
>> >was moved to source.squeak.org a long time ago.
>> >
>> >My apologies again!
>> >
>> >Dave
>> >
>> >> Hey Dave,
>> >>
>> >> I'm sure I'm messing something up but I can't find ImageFormat-dtl.26,
>> >> they only go up to
>> >> ImageFormat-dtl.12.  Am I looking in the wrong place?
>> >>
>> >> Lou
>> >>
>> >>
>> >> On Tue, 25 Jul 2017 14:06:30 -0400, "David T. Lewis" <
>> lewis at mail.msen.com>
>> >> wrote:
>> >>
>> >>>I guess I just forgot to upload it from my package-cache. Please try
>> >>> again
>> >>>with the ImageFormat-dtl.26 that I just uploaded, it should work now.
>> >>> Sorry
>> >>>for the confusion.
>> >>>
>> >>>Dave
>> >>>
>> >>>
>> >>>On Tue, Jul 25, 2017 at 01:54:43PM -0400, Louis LaBrunda wrote:
>> >>>> Hi Dave,
>> >>>>
>> >>>> Thanks Dave.  I will check tomorrow.  For now I will assume it will
>> get
>> >>>> fixed and work around
>> >>>> it.
>> >>>>
>> >>>> Lou
>> >>>>
>> >>>> On Tue, 25 Jul 2017 13:47:12 -0400 (EDT), "David T. Lewis"
>> >>>> <lewis at mail.msen.com> wrote:
>> >>>>
>> >>>> >Hi Lou,
>> >>>> >
>> >>>> >Ugh, I think that was due to a bug that I fixed not too long ago
>> (some
>> >>>> >missing methods for the latest Spur formats IIRC). I thought I had
>> >>>> >uploaded the fix but I do not see it in the repository. My apologies,
>> >>>> I
>> >>>> >will address it as quickly as I can, but it might not be until
>> >>>> tomorrow.
>> >>>> >
>> >>>> >Sorry,
>> >>>> >Dave
>> >>>> >
>> >>>> >
>> >>>> >> Hi Dave,
>> >>>> >>
>> >>>> >> Thanks you very much for the prompt reply.  I loaded the
>> ImageFormat
>> >>>> >> package as you suggested
>> >>>> >> into a fairly new 32 bit image.  But when I try ImageFormat
>> >>>> fromFile: to
>> >>>> >> that image of the
>> >>>> >> image with my program, I get an "unrecognized image format" error.
>> >>>> I will
>> >>>> >> keep trying more
>> >>>> >> after lunch but for now I don't get it?
>> >>>> >>
>> >>>> >> Lou
>> >>>> >>
>> >>>> >>
>> >>>> >> On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis"
>> >>>> >> <lewis at mail.msen.com> wrote:
>> >>>> >>
>> >>>> >>>Hi Lou,
>> >>>> >>>
>> >>>> >>>A simple check is to look at the first bytes of the image file,
>> >>>> which
>> >>>> >>>define the image format number. If the image format is something
>> >>>> >>>reasonable (presumably the same as whatever image you are replacing
>> >>>> in
>> >>>> >>>most cases), then you know that it is a Squeak image file, although
>> >>>> this
>> >>>> >>>will not tell you if the actual image is valid.
>> >>>> >>>
>> >>>> >>>To do this from a running Squeak image, try loading the ImageFormat
>> >>>> >>>package from the VMMaker repository on squeaksource.com. Look at
>> the
>> >>>> >>> class
>> >>>> >>>comments, and you will find methods for reading the image format
>> >>>> number
>> >>>> >>>from a file stream.
>> >>>> >>>
>> >>>> >>>There is also a C program called ckformat.c at
>> >>>> >>>http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C
>> code
>> >>>> is
>> >>>> >>>automatically generated from the ImageFormat package, so they the
>> do
>> >>>> the
>> >>>> >>>same thing. If you want to do the test from a shell script, as
>> >>>> opposed to
>> >>>> >>>doing it from the running image, then you can use this C program.
>> >>>> >>>
>> >>>> >>>Of course in theory you can load an entire image file into a VM
>> >>>> simulator
>> >>>> >>>with the VMMaker package, but that would not be a practical test
>> for
>> >>>> what
>> >>>> >>>you are trying to accomplish.
>> >>>> >>>
>> >>>> >>>If you need a better test of "valid" then you might consider using
>> >>>> >>>OSProcess/CommandShell to actually run the image file and see if it
>> >>>> >>> works.
>> >>>> >>>Probably you would do something like run it with a
>> PipeableOSProcess
>> >>>> >>>connected to your main Squeak image, and just kill the image under
>> >>>> test
>> >>>> >>>once you have confirmed that it runs.
>> >>>> >>>
>> >>>> >>>Dave
>> >>>> >>>
>> >>>> >>>> Hi All,
>> >>>> >>>>
>> >>>> >>>> Can a running Squeak program look at a Squeak image file and know
>> >>>> if it
>> >>>> >>>> is
>> >>>> >>>> a good image?  I'm
>> >>>> >>>> working on a program that the user won't have easy access to.  I
>> >>>> would
>> >>>> >>>> like to allow its
>> >>>> >>>> replacement with a new version.  I think I know how to do that
>> but
>> >>>> >>>> would
>> >>>> >>>> like to see if I can
>> >>>> >>>> program in some protection from the user replacing the image with
>> >>>> a bad
>> >>>> >>>> or
>> >>>> >>>> completely wrong
>> >>>> >>>> file.  Any ideas?
>> >>>> >>>>
>> >>>> >>>>
>> >>>> >>>> Lou
>> >>>> >>>> --
>> >>>> >>>> Louis LaBrunda
>> >>>> >>>> Keystone Software Corp.
>> >>>> >>>> SkypeMe callto://PhotonDemon
>> >>>> >>>>
>> >>>> >>>>
>> >>>> >>>>
>> >>>> >>>
>> >>>> >>>
>> >>>> >>>
>> >>>> >> --
>> >>>> >> Louis LaBrunda
>> >>>> >> Keystone Software Corp.
>> >>>> >> SkypeMe callto://PhotonDemon
>> >>>> >>
>> >>>> >>
>> >>>> >>
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> --
>> >>>> Louis LaBrunda
>> >>>> Keystone Software Corp.
>> >>>> SkypeMe callto://PhotonDemon
>> >>>>
>> >>>>
>> >>>
>> >> --
>> >> Louis LaBrunda
>> >> Keystone Software Corp.
>> >> SkypeMe callto://PhotonDemon
>> >>
>> >>
>> >>
>> >
>> >
>> >
>> --
>> Louis LaBrunda
>> Keystone Software Corp.
>> SkypeMe callto://PhotonDemon
>>
>>
>>
-- 
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon



More information about the Squeak-dev mailing list