Documenting the Source
As you maybe know I have a new job since last December and I'm working on
Samba4 now. Samba4 is a monster so I've asked for some simple tasks to get
started. The task was to migrate some code to a new Samba library called
tsocket. The problem was I didn't know what to do and how. Some functions
of the API were documented but not all. So I had to guess from the names
what the function is doing and read the code to understand it. Then I've
started to work with the interface and I had to look again the the code to
find out possible return values. In the end I spent a lot of time jumping
through the source code to find out the return values for the functions.
If the API would be completely documented I could get my work done a lot of
faster so I simply started to document it cause I had to understand it anyway.
I've decided to write the documentation with doxygen and put it in the header
file, so that people who use the PAI always have the documentation with them.
After I finished it, started to work on the source code again and got some
things working as I was able to understand the API of the library. Then I
crossed the next undocumented API of a library. Ok, it wasn't undocumented it
had a text file describing everything but having doxygen documentation is much
nicer than a text file. So I've started to document talloc from Samba4 with
doxygen.
The talloc API uses macros for a lot of things to make debugging easier or
to hide things you're doing from the user. However if you document a macro
than normally you want that it looks like a function. To be able to do that
with doxygen you have to use a little trick. As doxygen has a C preprocessor
built in you can create a define for a doxygen mode. That's what I've done in
the config file and all you need to do in the source code is to use it with
#ifdef.
#ifdef DOXYGEN
/**
* @brief Create a new talloc context.
*
* The talloc() macro is the core of the talloc library. It takes a memory
* context and a type, and returns a pointer to a new area of memory of the
* given type.
*
* The returned pointer is itself a talloc context, so you can use it as the
* context argument to more calls to talloc if you wish.
*
* The returned pointer is a "child" of the supplied context. This means that if
* you talloc_free() the context then the new child disappears as well.
* Alternatively you can free just the child.
*
* @param[in] ctx A talloc context to create a new reference on or NULL to
* create a new top level context.
*
* @param[in] type The type of memory to allocate.
*
* @return A type casted talloc context or NULL on error.
*
* @code
* unsigned int *a, *b;
*
* a = talloc(NULL, unsigned int);
* b = talloc(a, unsigned int);
* @endcode
*
* @see talloc_zero
* @see talloc_array
* @see talloc_steal
* @see talloc_free
*/
void *talloc(const void *ctx, #type);
#else
#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
void *_talloc(const void *context, size_t size);
#endif
So start to document your API. What you get well be something like this and other will love it!
csync at FOSDEM
I'm currently updating csync to work with libssh 0.4 and I will give a lightning talk about csync at FOSDEM next weekend. csync is a file synchronizer to keep two folders in sync. This can be local or remote. The main purpose of csync is to provide Roaming Home Directories.
I will work with Aris on libssh stuff and try to get some small features in KDE for kio_sftp. I heard that some KDE guys are around too. I hope to see you there.
If you're a Samba developer and go to FOSDEM, let me know
mlmmj webarchiver
I run mlmmj (mailinglist management made joyful) for my mailing lists. The problem was, that I didn't have any mailinglist webarchives for a long time. I had to change this so I started on Friday to changes this. It took me the whole day to write the scripts. mlmmj-webarchiver has been written by Sven Michels using hypermail. As hypermail is more or less a dead project I decided to use mhonarc. So I started to rewrite the script and use the theme the roundcube project created.
You can see the result here:
http://www.libssh.org/archive/
http://www.csync.org/archive/
I've created a git repository for the mlmmj-webarchiver:
git clone git://git.cynapses.org/users/gladiac/mlmmj-webarchiver.git
Patches are welcome
undefined reference to “function name”
Since hermes is flooding my mailbox I haven't looked if all my packages are compiling on Factory. So I had a look for interesting emails today. ctrlproxy (irc proxy/bouncer) didn't build with undefined reference to "
The problem is the linking order of the libraries and source code! Lets look at an example:
Assume that you built a static library libwurst and it uses the pow() function from the math library.
$ gcc -Wl,--as-needed --static main.c -o wurstsalat -L. -lm -lwurst
./libwurst.a(wurst.o): In function `wurst':
wurst.c:(.text+0x29): undefined reference to `pow'
The problem here is, that the linker doesn't find any reference to pow() in main.c. Then the first library is libm and as it is not needed, the linker skips it. So you have to link against libwurst.a before you link against libm.
$ gcc -Wl,--as-needed --static main.c -o wurstsalat -L. -lwurst -lm
To summarize it: When using --as-needed, the order in which the libraries appear in the command line is relevant: any library X must precede all libraries Y that offer symbols that X uses.
I've created a page in the openSUSE wiki, you can find it here.
kio_sftp authentication with libssh works
I've got the fingerprint verification and authentication with public key and keyboard interactive working. There is still a dialog missing for special interactive questions, but the normal user stuff works just fine.
csync with sftp support
I've released a new version of csync with sftp support. csync is a bidirectional file synchronizer for Linux and allows to keep two copies of files and directories in sync. It uses widely adopted protocols like smb or sftp so that there is no need for a server component of csync. It is a user-level program which means there is no need to be a superuser.
libssh 0.3.0
After several month of hard work, rewriting nearly all libssh functions, I've released version 0.3.0 today. Read more about the release here. A new version of csync with full sftp support will be released soon.
Automatic testing of PAM modules
Last week at the SambaXP conference I had a discussion with Günther Deschner about the testing of PAM modules. What we want to do is automatic testing. To achieve this in the Samba build farm you need a separate "pam.d" config directory for testing. You should be able to change the config and mess it up without getting locked out.
I've introduced a new function to PAM called pam_start_test() which takes and additional argument where you can specify the config directory. After this I've changed the call in pamtester and added a commandline option for the config directory. To do automatic testing I've added another commandline option to specify the password to use for authentication.
gladiac@maximegalon:~> pamtester -v -C/tmp/pam.d -Psecret login csync authenticate
pamtester: invoking pam_start(login, csync, ...)
pamtester: performing operation - authenticate
pamtester: successfully authenticated
You can find the patches here.
This and that
ssh-agent client support for libssh
As you might know I develop csync which is a file synchronizer. To support sftp I'm using libssh. libssh is designed to be used by programmers needing a working SSH implementation by the mean of a library. I think it is nearly feature complete. I've cleaned up the sftp interface last year. The only thing missing was ssh-agent support. This is implemented now in the subversion trunk and will be released as libssh 0.3. I hope we can do a release soon.
