All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
To: Ivan Gyurdiev <ivg2@cornell.edu>
Cc: Joshua Brindle <jbrindle@tresys.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	SELinux List <SELinux@tycho.nsa.gov>
Subject: Re: [ SEPOL ] Move more things to newer debug system
Date: Wed, 14 Sep 2005 08:00:22 +0100	[thread overview]
Message-ID: <20050914070022.GD1257@lkcl.net> (raw)
In-Reply-To: <432799F0.7060706@cornell.edu>

On Tue, Sep 13, 2005 at 11:33:04PM -0400, Ivan Gyurdiev wrote:
> >The error system should be about passing descriptive messages to the
> >caller and this needs to be done by passing a buffer to the functions
> >that may return an error,
> >
> How do we pass such a buffer without rewriting the libsepol API?
> DEBUG has the advantage of being backwards compatible.
 
 okay.

 i refrained from replying regarding library design, which i
 learned about from an expert - andrew tridgell.  i refrained
 because i believed i would be seen as attemtping to teach
 people who already knew about these matters.
 
 given that there have now been at least three messages bouncing
 back-and-forth indicating that there have been some quite
 serious basic design mistakes (global variables, printfs for debug
 reporting etc.), i thought it best to chip in.

 properly libraries should never call _any_ functions that it has not
 explicitly been given access to.

 if there are lots of functions it needs, then the library should be
 passed in an array (vector table) of those functions.

 the best designed libraries should have ONE external function
 and ZERO global variables.  the external function should
 be setup function which returns a vector table pointing to
 static internal functions.

 one of those static internal functions should be an "initialisation"
 function, via which the library should RECEIVE a vector table pointing
 to functions that it needs to make use of - the most obvious ones being
 of course malloc, free and realloc.


 stuff backwards compatibility - royally.
 
 design the library properly.

 pass in a pointer to a memory free and a memory alloc function.

 pass in a debug reporting function, with clear instructions
 that the memory allocated to report the error should be freed
 by the caller (or some other technique e.g. a negotiation
 technique to request a buffer for error reporting of minimum
 size X, which could be static).

 
 the extreme case of library development is kernel programming,
 especially in Windows NT's design, for example the LSA -
 local security authority.  mostly, in NT, things are designed
 the way they are because MS can't make up their minds as
 to whether to have code in kernel or in userspace, so they
 design everything for kernelspace, just in case.

 anyway.


 i strongly advise you to consider _not_ putting backwards
 compatibility as a high priority over good library design.

 and to treat the library as if it was to be put into the
 linux kernel.

 l.


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  parent reply	other threads:[~2005-09-14  7:00 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-12 12:06 [ SEMANAGE ] Stub out user/port functionality Ivan Gyurdiev
2005-09-12 14:14 ` [ SEMANAGE ] Introduce record table Ivan Gyurdiev
2005-09-13  3:55   ` [ SEPOL ] Move more things to newer debug system Ivan Gyurdiev
2005-09-13 19:59     ` Stephen Smalley
2005-09-13 22:26       ` Ivan Gyurdiev
2005-09-13 23:03         ` Joshua Brindle
2005-09-14  3:33           ` Ivan Gyurdiev
2005-09-14  3:37             ` Ivan Gyurdiev
2005-09-14 13:16               ` Stephen Smalley
2005-09-14 14:05                 ` Dale Amon
2005-09-14 18:07                   ` Stephen Smalley
2005-09-14 23:44                     ` Dale Amon
2005-09-14  7:00             ` Luke Kenneth Casson Leighton [this message]
2005-09-14 12:11               ` Stephen Smalley
2005-09-14  7:01             ` Luke Kenneth Casson Leighton
2005-09-14 13:00             ` Stephen Smalley
2005-09-14 13:21               ` Joshua Brindle
2005-09-14 13:51                 ` Stephen Smalley
2005-09-14 14:45                   ` Joshua Brindle
2005-09-14 15:04                     ` Stephen Smalley
2005-09-14 15:26                       ` info on SELinux support for IPSEC Prakash Saivasan
2005-09-14 18:20                         ` Stephen Smalley
2005-09-14 15:33                       ` [ SEPOL ] Move more things to newer debug system Joshua Brindle
2005-09-14 15:38                         ` Stephen Smalley
2005-09-14 16:06                           ` Joshua Brindle
2005-09-14 16:24                             ` Stephen Smalley
2005-09-14 17:16                               ` Ivan Gyurdiev
2005-09-14 17:21                                 ` Ivan Gyurdiev
2005-09-14 18:53                                 ` Stephen Smalley
2005-09-16 13:48                                 ` Luke Kenneth Casson Leighton
2005-09-14 19:37                             ` Ivan Gyurdiev
2005-09-14 19:50                               ` Stephen Smalley
2005-09-14 20:01                                 ` Stephen Smalley
2005-09-14 20:32                                 ` Ivan Gyurdiev
2005-09-15  7:31                                   ` Ivan Gyurdiev
2005-09-15 12:22                                     ` Stephen Smalley
2005-09-15 13:01                                     ` Stephen Smalley
2005-09-15 15:17                               ` Stephen Smalley
2005-09-15 16:03                                 ` Ivan Gyurdiev
2005-09-16 12:19                                   ` Stephen Smalley
2005-09-18  3:14                                     ` Ivan Gyurdiev
2005-09-16 13:45                               ` Luke Kenneth Casson Leighton
2005-09-16 13:55                           ` Luke Kenneth Casson Leighton
2005-09-18  3:16                           ` Ivan Gyurdiev
2005-09-18  3:52                             ` Ivan Gyurdiev
2005-09-18 15:45                               ` Ivan Gyurdiev
2005-09-19 12:49                               ` Stephen Smalley
2005-09-19 14:05                                 ` Ivan Gyurdiev
2005-09-19 14:45                                   ` Stephen Smalley
2005-09-19 16:24                                     ` Ivan Gyurdiev
2005-09-19 16:49                                       ` Stephen Smalley
2005-09-19 17:16                                         ` Ivan Gyurdiev
2005-09-19 18:26                                           ` Stephen Smalley
2005-09-14 19:57                     ` Ivan Gyurdiev
2005-09-14 12:35         ` Stephen Smalley
2005-09-14 15:51     ` Stephen Smalley
2005-09-13 19:43   ` [ SEMANAGE ] Introduce record table Stephen Smalley
2005-09-13 22:15     ` Ivan Gyurdiev
2005-09-13 22:46       ` Ivan Gyurdiev
2005-09-14 15:46   ` Stephen Smalley
2005-09-14 15:45 ` [ SEMANAGE ] Stub out user/port functionality Stephen Smalley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050914070022.GD1257@lkcl.net \
    --to=lkcl@lkcl.net \
    --cc=SELinux@tycho.nsa.gov \
    --cc=ivg2@cornell.edu \
    --cc=jbrindle@tresys.com \
    --cc=sds@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.