Package: ltsp-client-core
Version: 5.1.90-1
Severity: wishlist
Tags: patch
It would be useful if getltscfg would support wildcards, e.g.:
[00:0C:6E:*]
XSERVER = nvidia
This is very useful in order to have specific settings for a subset of
computers. E.g. when buying a large number of computers of the same
model, they will usually have one or two MAC address series which can be
matched. The alternative is to add a separate section for each
computer, which requires a lot of work.
I have attached a patch which implements this, but while it seems to
work I can't guarantee that it's 100% correct.
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (900, 'testing'), (800, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.26-2-686 (SMP w/1 CPU core)
Locale: LANG=nb_NO.UTF-8, LC_CTYPE=nb_NO.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
--- getltscfg.c.orig 2009-09-18 14:16:49.000000000 +0200
+++ getltscfg.c 2009-10-13 12:24:56.000000000 +0200
@@ -28,6 +28,8 @@
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#define _GNU_SOURCE /* need the fnmatch FNM_CASEFOLD flag */
+#include <fnmatch.h>
#include "getltscfg.h"
extern FILE *yyin;
@@ -191,13 +193,17 @@
//
// find_chain_entry(), returns TRUE if it found the entry, and FALSE otherwise
//
-int find_chain_entry(char *name)
+int find_chain_entry(char *name, int glob)
{
int fFound = FALSE;
SECTTYPE *worksect;
cursect = headsect;
+ int matches = FALSE;
while( cursect && !fFound ){
- if(strcasecmp(cursect->name,name) == 0){
+ matches = strcasecmp(cursect->name,name) == 0;
+ if (glob)
+ matches = !matches && fnmatch(cursect->name, name, FNM_CASEFOLD) == 0;
+ if(matches){
CHAINTYPE *chainptr = (CHAINTYPE *)malloc(sizeof(CHAINTYPE));
worksect = cursect;
fFound = TRUE;
@@ -429,8 +435,8 @@
// that we are interested in. Then, walk through the linked list
// looking for any entries that indicate we want to "inherit" entries
// from another section. We'll build a new linked list of those
- // sections that we want to inherit from. Then, we'll tack the 'Default'
- // section on the end of that. Once we have the inheritance list, we
+ // sections that we want to inherit from. Then, we'll tack any wildcard matches
+ // and the 'Default' section on the end of that. Once we have the inheritance list, we
// need to walk that list backwards, building the list of
// tuples (keyword/value pairs).
// Finally, when we are all done, we should have all of the values that
@@ -447,7 +453,7 @@
i = 0;
fFound = FALSE;
while( aWorkstationId[i] && !fFound ){
- if(find_chain_entry(aWorkstationId[i])){
+ if(find_chain_entry(aWorkstationId[i], FALSE)){
fFound = TRUE;
}
i++;
@@ -458,17 +464,33 @@
curtuple = chain->sect->tuple_list;
while(curtuple){
if(strcasecmp(curtuple->keyword,"LIKE") == 0)
- status = find_chain_entry(curtuple->value);
+ status = find_chain_entry(curtuple->value, FALSE);
curtuple = curtuple->next;
}
chain = chain->next;
}
+ for (i=0; aWorkstationId[i]; ++i){
+ if((status = find_chain_entry(aWorkstationId[i], TRUE))){
+ chain = headchain;
+ while(chain){
+ curtuple = chain->sect->tuple_list;
+ while(curtuple){
+ if(strcasecmp(curtuple->keyword,"LIKE") == 0)
+ status = find_chain_entry(curtuple->value, FALSE);
+
+ curtuple = curtuple->next;
+ }
+ chain = chain->next;
+ }
+ }
+ }
+
//
// the last entry in the chain is the '[Default]' entry
//
- status = find_chain_entry("default");
+ status = find_chain_entry("default", FALSE);
curchain = tailchain;