discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running a separate script from my app using NSBundle, NSTask


From: Richard Frith-Macdonald
Subject: Re: Running a separate script from my app using NSBundle, NSTask
Date: Fri, 12 Nov 2010 10:07:38 +0000

On 12 Nov 2010, at 10:29, Csanyi Pal wrote:

> Hello,
> 
> SPUeNTRUP - Kai Henningsen <Kai.Henningsen@cats.ms> writes:
> 
>> Am Tue, 02 Nov 2010 18:28:54 +0100
>> schrieb Csanyi Pal <csanyipal@gmail.com>:
>> 
>> Let me just point out that there is never a need to run gcc as root
>> (and in fact it is usually a bad idea, as it hasn't been audited to be
>> safe). The right way to do this is something along these lines:
>> 
>> $ gcc -ggdb -O DPResetBit0.c -o DPResetBit0
>> $ sudo chown root:root DPResetBit0
>> $ sudo chmod +s DPResetBit0
>> 
>> ... or just
>> 
>> $ make
>> $ sudo make install
>> 
>> (which I believe is one of the major reasons for having a separate
>> install target in the first place).
> 
> Thanks!
> 
> I try to create a separate Makefile only to compile those C scripts to
> get DPResetBit0, DPResetBit1, ..., DPResetBit7 and to
> get DPSetBit0, DPSetBit1, ..., DPSetBit7
> executables that can run with root permissions.
> This is the only way to access the parallel port. 
> 
> Then I want to run those executables from my LPT_Interface.app app using
> NSTask. 
> 
> So I want to edit my GNUmakefile to get compiled those C files into my
> app. I tried to create a separate Makefile to compile only these C
> sources, and try to include this Makefile into GNUmakefile but then I
> get compiled only C executables but not get the LTP_Interface.app.

1. You don't want the C files compiled into your app ... you want to 
  a. build executables from the C files and
  b. have your app run those executables as subtasks.

2. You can simply use a single GNU makefile to do all the build/install

To build the C files you do something like this:

CTOOL_NAME = DPResetBit0 ... DPResetBit7 DPSetBit0 ...

And a line for each tool you want to build:

eg.
DPResetBit0_C_FILES = DPResetBit0.c
DPResetBit1_C_FILES = DPResetBit1.c
and so on.

and your makefile needs to include the rules for building C tools:

include $(GNUSTEP_MAKEFILES)/ctool.make


And if you want to install the tools setuid to be run by root (which is a 
dangerous thing to be done only with care/consideration), you can add a rule to 
do that with a series of commands to 

after-install::
        $(INSTALL) -m 05755 $(GNUSTEP_OBJ_DIR)/DPResetBit0 
$(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_DIR); \ 
        $(INSTALL) -m 05755 $(GNUSTEP_OBJ_DIR)/DPResetBit1 
$(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_DIR); \ 

or you could write a loop to install all the tools setuid rather than 
instaslling each separately:

for tool in $(CTOOL_NAME) ....




reply via email to

[Prev in Thread] Current Thread [Next in Thread]