• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Authorization.h
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Authorization.h


  • Subject: Re: Authorization.h
  • From: Eric Peyton <email@hidden>
  • Date: Fri, 2 Nov 2001 15:41:46 -0600

You need to make your own protocol for the connection. The ServerProtocol is just that ...

Here is a snippet of the docs ...

The invocation of setProtocolForProxy: informs the distributed objects system of the set of messages that theProxy responds to. Normally, the first time a particular selector is forwarded by a proxy the NSConnection object must confirm the argument and return types with the real object. This can add significant overhead to distributed messages. Setting a protocol records this information so that no confirmation is needed for the messages in the protocol, and only the message forwarding costs are incurred.

You need to declare your own protocol (i.e. the messages you plan on sending).

it will look something like this.

@protocol ServerProtocol

- (void)registerAgent:(NSDistantObject *)agent;
- (void)addMessageToLog:(NSString *)output;

...

@end

// messages you plan on sending from the server to the client
@protocol ClientProtocol

- (void)terminate;

@end

etc.

These are the messages you are planning to send from the distant object to the local server object.

I suspect that if you look on one of the developer sites or in Apple's examples you will find a simple DO example someplace, but I am not familiar with those examples.

Eric

On Friday, November 2, 2001, at 03:35 PM, Josh M. Hurd wrote:

I read through the docs for NSConnection, found a snipet of code there which I copied into my app. I get the following error message when I build:

Cannot find protocol declaration for 'ServerProtocol'

the code snipet is:

id theProxy;
theProxy = [[NSConnection rootProxyForConnectionWithRegisteredName:@"server" host:@"*"] retain];
[theProxy setProtocolForProxy:@protocol(ServerProtocol)];

I looked through the docs for NSProxy, NSDistantObject and found no reference to this.

What type of protocol do I need here or where can I find docs for these protocols?

Thanks again!

M

On Friday, November 2, 2001, at 12:32 PM, Eric Peyton wrote:


On Friday, November 2, 2001, at 02:16 PM, Josh M. Hurd wrote:

Actually I did spend about two hours reading the archives but was hoping that something had changed or someone knew a trick that wasn't mentioned there. I knew someone would come back and tell me to read the archives, thanks for being consistent! And thanks for the other suggestions too! Unfortunately I know little about inter-app communications, guess it's time to learn...


Look at some simple DO apps (read the class docs on NSConnection). I whipped up my first app like this in about 30 minutes. It's really very easy.

So is this a BSD thing / a limitation of the underlying OS

It is a feature of the underlying OS, definitely NOT a limitation.

or is this something that Apple just hasn't gotten to? Are there any plans on changing this?


No. I do not believe there are any plans to even think about changing this.

Eric

Thanks for the help!

M

On Friday, November 2, 2001, at 05:46 AM, Eric Peyton wrote:

On Friday, November 2, 2001, at 03:06 AM, Josh M. Hurd wrote:

How can I use the Security framework (Authorization.h) to 'executeWithPrivileges' a function or method call instead of an executable?


You can't.

I suggest you read the copious number of emails regarding this exact issue going back over the last 6-9 months on this list and the omnigroup list (email@hidden). This question (and variants upon it) have been asked numerous times.

Pertinent notes.

) A non-root application cannot in any way switch to being root, do something and then switch back. You need to be root first (run by root or setuid(root)). Therefore, you cannot execute one function or method as root. This is a design of the operating system.

) executeWithPrivileges has a lot of features and drawbacks. Many of these emails cover them in depth.

) To do what you want, you will most likely need to create another binary with the correct "function" or "method" and associated data, launch that binary using AuthorizationExecuteWithPrivileges, then open a communication channel between your application and the launched application (ports, sockets, DO, mach messages, voodoo, mind reading - pick your favorite protocol - I usually use DO), share information, do x,y and z as root, and then quit the launched binary.

Eric

Thanks,

M
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


  • Follow-Ups:
    • Re: Authorization.h
      • From: "Josh M. Hurd" <email@hidden>
References: 
 >Re: Authorization.h (From: "Josh M. Hurd" <email@hidden>)

  • Prev by Date: Re: Authorization.h
  • Next by Date: Re: Authorization.h
  • Previous by thread: Re: Authorization.h
  • Next by thread: Re: Authorization.h
  • Index(es):
    • Date
    • Thread