Linux Port :)

You have successfully tested a non-tested PIC model, programmer interface, created a new devices.ini paragraph, performed a new translation, don't hesitate to publish that information here.

Re: Linux Port :)

Postby Death Knight » 10, 2010 Nov Wed 10:55 pm

I fixed make file slightly. And prepares rpm package. Looks good.
I noticed that all help and docs goes to /usr/share/wxpic/help directory.
I think at least some of them (like Author.txt, DocWriter.txt, License.txt, Translator.txt) needed to go to /usr/share/doc/wxpic directory for proper placement.
But they are working in this style too. I don't understand newer makefile installation routines but you have to know that, makefile connected to wxpic.spec file.
All files that installed to computer needed to be defined in this file. I add all files definitions by hand...

There is "Unknown Version" problem on build that compiled by Makefiles. Even if there is version.autogen file put by hand. I think you just forgotten to put required flags to makefile.
I think it's time to merge changes to trunk. After I can generate packages for RPM distros officially..
Death Knight
 
Posts: 53
Joined: 30, 2010 May Sun 10:18 pm

Re: Linux Port :)

Postby admin » 02, 2011 Jan Sun 1:39 pm

Hi Erdem,
I wish you a happy new Year.

I tried to test your .spec but I don't see how to use it. I had a lot of other projects running so it took me some time before digging on what can be done with a .spec file.
My Ubuntu indicates that this is a RPM file and that I need to install RPM. So I did it. Then I tried to run RPM with that spec file. I had to ask to Google how RPM uses a spec file and I think I must use in fact rpmbuild.

I run rpmbuild on the .spec. But it asked me for a source file tar! I would have expected the packager to build that source package itself not to ask me to build it myself. This is not my logic that starts from an up to date working copy to generate the binary package and the source package but this is a logic where you build the binary package from the source package that has been built previously.
So I build a tar file with the sources files with the name it requested. Then I retried and this time it requested me the depending packages that I already have but not in RPM flavour.

I stopped there because I don't know how to install those RPM packages on Ubuntu. So I don't see how the spec file can help to package WxPic under Ubuntu.
Nevertheless I fixed a non technical error in the spec and I modified the changes in the makefile so that they are homogeneous.

Regards,
Philippe
admin
Site Admin
 
Posts: 153
Joined: 12, 2009 Jul Sun 7:20 pm

Re: Linux Port :)

Postby Death Knight » 04, 2011 Jun Sat 9:47 pm

Hi, I return...
Unfortunately I leaved PIC architecture...
But I can look what happen...

Firstly, RPM is not for debian. In linux there is 2 major packaging. One of it is debian, that requires debian control files for make it.
Other one is RPM, that requires spec file... I will prepare deb control files soon, while I make it for wxhexeditor/meteorite. They need debian control files too...

I see that you have 2 problems
Known problems:
#0000059: Under LINUX, if the parallel port is used and WxPic is NOT run with root credentials (sudo), WxPic will crash with a segment violation.
#0000060: Under LINUX, If WxPic is run WITH root credentials (sudo) and the help is requested, your browser will be called with root credential so it will write its configuration with those credentials, preventing any later access to the browser without them

What about if you to request root access and abort operation if there is no root permissions?
I solve that problem at wxhexeditor by such a code. you can copy it.
Code: Select all
#ifndef __WXMSW__
   while( not myfilename.IsFileReadable() ) { //IsFileReadable
      if( wxCANCEL == wxMessageBox(_("File is not readable by permissions.\n Do you want to own the file?"),_("Error"), wxOK|wxCANCEL|wxICON_ERROR) )
         break;

      wxArrayString output,errors;

      //Save old owner to update at file close...
      wxExecute( wxT("stat -c %U ")+myfilename.GetFullPath(), output, errors, wxEXEC_SYNC );
      if(output.Count()>0 and errors.Count()==0)
         oldOwner = output[0];//this return root generally :D
      else{
         wxMessageBox(_("Unknown error on \"stat -c %U")+myfilename.GetFullPath()+wxT("\""),_("Error"), wxOK|wxCANCEL|wxICON_ERROR);
         return;
         }
      //Changing owner of file...
      //I think it's better than changing permissions directly. Doesn't it?
      //Will restore owner on file close.
      wxString cmd = wxT("gnomesu -c \"chown ") + wxGetUserId() + wxT(" ")+ myfilename.GetFullPath() +wxT("\"");
#ifdef _DEBUG_
      std::cout << "Changing permission of " << myfilename.GetFullPath().ToAscii() << std::endl;
      std::cout << cmd.ToAscii() << std::endl;
#endif
      //wxExecute( cmd , output, errors, wxEXEC_SYNC);
      wxShell( cmd );
      }
#endif


I think this will solve this two problem.
Do you test wxpic on Mac?
Do you like If I make it?

I remember also, you can use static building at linux binaries that remove libwxgtk dependency. Which is a good thing. (or not? :) )
Death Knight
 
Posts: 53
Joined: 30, 2010 May Sun 10:18 pm

Re: Linux Port :)

Postby admin » 05, 2011 Jun Sun 12:16 pm

Hi Erdem,

Welcome back.

Your idea for testing if we are root is interesting. But what would be the right Unix command to request root access? In your example I see mainly access to file. I could try to request write access to a system file such as /etc/hosts. But that's not clean. This could look like a malware trying to alter the computer. Is there any better way to ask Linux whether you are root user?

For the help issue, the problem is more complex. Because I cannot restore the file ownership modified by the browser as you do in your example because I don't know which files are modified by the browser. My idea was rather to set the home directory of the browser running context to root home directory so that it will modify files that are not the user files. But I don't know how it is possible to go further than sudo: sudo changes only the privilege level but not the current user. I would like my help browser to actually be root to access only root files.

I have no MAC and no MAC emulator at this time. So I have not even thought to trying WxPic on MAC!
If you have some hardware available, why not testing on MAC !

About static building, this can be an improvement when you deliver the program as a binary tar (as I did) so that users don't have to search for missing libraries. But if it is delivered as a package, I suppose it is better to let the package manager to get libwxgtk automatically.

Regards,
Philippe
admin
Site Admin
 
Posts: 153
Joined: 12, 2009 Jul Sun 7:20 pm

Re: Linux Port :)

Postby Death Knight » 26, 2011 Jun Sun 2:59 am

Your idea for testing if we are root is interesting. But what would be the right Unix command to request root access? In your example I see mainly access to file. I could try to request write access to a system file such as /etc/hosts. But that's not clean. This could look like a malware trying to alter the computer. Is there any better way to ask Linux whether you are root user?


No, if we are root, than we have already rw access to any file. So code doesn't request for anything. That code just change file owner to user for a while to have r/w access if file can't open by permissions... Since user has to know "root password" to issue that port owner change command, it's normal that he could also change /etc/hosts file with it also. If you have root command, you can issue anything. It's not malware approach but standard linux rule... If root doesn't want to user to do that, its also displayed which file wanted to open at that owner change screen. There is nothing weird on this.

For the help issue, the problem is more complex. Because I cannot restore the file ownership modified by the browser as you do in your example because I don't know which files are modified by the browser. My idea was rather to set the home directory of the browser running context to root home directory so that it will modify files that are not the user files. But I don't know how it is possible to go further than sudo: sudo changes only the privilege level but not the current user. I would like my help browser to actually be root to access only root files.

Hey, you don't needed to execute browser with the code at top... Since users just changed Serial ports owner, program doesn't run as a root user! There is no need for that anymore. So no one needs to use program with sudo command... Does it clear?

I have no MAC and no MAC emulator at this time. So I have not even thought to trying WxPic on MAC!
If you have some hardware available, why not testing on MAC !

Unfortunately, your program resist to run even on my linux. It show licence.txt bla bla... than closes...
Why do you needed those licenses for program running? You needed to include that license into code. Program needed to be executed by exe.
I can't run it even from codeblocks. There is some problems when I run program, couldn't find license dir....

About static building, this can be an improvement when you deliver the program as a binary tar (as I did) so that users don't have to search for missing libraries. But if it is delivered as a package, I suppose it is better to let the package manager to get libwxgtk automatically.
I just say for static binaries. I released like that. rpm compile farm handles the requirements. But since your program has problem with startup I cannot look and try to put debian control files nor broken spec file...
Regards
Erdem
Death Knight
 
Posts: 53
Joined: 30, 2010 May Sun 10:18 pm

Re: Linux Port :)

Postby admin » 26, 2011 Jun Sun 11:01 pm

Death Knight wrote:Hey, you don't needed to execute browser with the code at top... Since users just changed Serial ports owner, program doesn't run as a root user! There is no need for that anymore. So no one needs to use program with sudo command... Does it clear?

Well, to be honest No :?
I have no problem with the serial port. The problem I had was with the parallel port. The access to the parallel port requires to be root. Even if the device is unprotected. Because the actual I/O does not use the device but an outb or inb instruction that in any case requires to be root. As I did not understood what you mean I review the code in case this would help to clarify. I did not find a clarification but I found 2 or 3 problems in the area of the parallel port opening that explains the crash when using parallel port without privilege. I fixed them and now one of the 2 problems is solved.
It remains the help issue. I see only one solution to it: blocking call to the help when WxPic is running with root privilege but in a non-root account.

Unfortunately, your program resist to run even on my linux. It show licence.txt bla bla... than closes...
Why do you needed those licenses for program running? You needed to include that license into code. Program needed to be executed by exe.
I can't run it even from codeblocks. There is some problems when I run program, couldn't find license dir....

I have added some tests at WxPic startup to verify if it is correctly installed. I prefer that a wrong installation is clearly detected rather than leading to strange bugs later. So either you must install the complete binary tar file tree or you can use make test to build the test environment for generated exe. First link the binary so that the target (release and/or debug) directory exists. Then use make test so that all necessary files are installed in this or these directory/ies.

Regards,
Philippe
admin
Site Admin
 
Posts: 153
Joined: 12, 2009 Jul Sun 7:20 pm

Previous

Return to WxPic contributions

cron