trac + rss-reader login
April 11, 2009
To be able to read a trac-rss from within an rss reader it is necessary to patch trac to request authentication instead of returning an error message via http if the user is not authenticated.
This can be done using the following patch which is menat to work against 0.11 and can be made to work against 0.10.4
diff --git a/trac/web/api.py b/trac/web/api.py
--- a/trac/web/api.py
+++ b/trac/web/api.py
@@ -181,6 +181,9 @@
doc='The HTTP method of the request')
path_info = property(fget=lambda self: self.environ.get('PATH_INFO', '').decode('utf-8'),
doc='Path inside the application')
+ query_string = property(fget=lambda self: self.environ.get('QUERY_STRING',
+ ''),
+ doc='Query part of the request')
remote_addr = property(fget=lambda self: self.environ.get('REMOTE_ADDR'),
doc='IP address of the remote user')
remote_user = property(fget=lambda self: self.environ.get('REMOTE_USER'),
diff --git a/trac/web/auth.py b/trac/web/auth.py
--- a/trac/web/auth.py
+++ b/trac/web/auth.py
@@ -197,7 +197,7 @@
def _redirect_back(self, req):
"""Redirect the user back to the URL she came from."""
- referer = req.get_header('Referer')
+ referer = req.args.get('referer', req.get_header('Referer'))
if referer and not (referer == req.base_url or \
referer.startswith(req.base_url.rstrip('/')+'/')):
# only redirect to referer if it is from the same site
diff --git a/trac/web/href.py b/trac/web/href.py
--- a/trac/web/href.py
+++ b/trac/web/href.py
@@ -129,7 +129,7 @@
if type(value) in (list, tuple):
for i in [i for i in value if i != None]:
params.append((name, i))
- elif v != None:
+ elif value != None:
params.append((name, value))
if args:
diff --git a/trac/web/main.py b/trac/web/main.py
--- a/trac/web/main.py
+++ b/trac/web/main.py
@@ -437,6 +437,11 @@
data = {'title': title, 'type': 'TracError', 'message': e.detail,
'frames': [], 'traceback': None}
try:
+ if e.code == 403 and req.authname == 'anonymous':
+ referer = env.abs_href(req.path_info)
+ if req.query_string:
+ referer += '?' + req.query_string
+ req.redirect(env.href('login', {'referer': referer}))
req.send_error(sys.exc_info(), status=e.code, env=env, data=data)
except RequestDone:
pass
Real Offline RSS Reader
März 20, 2009
It seems like I am not the only person in the need of an rss reader that is capable of fetching the articles including the link in each article for offline reading. [1]
Since I am aware of only one rss offline reader (straw) which currently segfaults before it even starts on my FreeBSD system, I decided to make my own using various parts.
I am using akregator as rss reader, pdnsd and wwwoffle for the caching part and a little bash script to fetch the articles.
The logic in the script detecting internal links is rather nasty since I am not using any xml dtd. Nevertheless it works for me and I can finally read news when I am riding on a train.
#!/bin/bash
akregatorFeeds="/home/erika/spielwiese/akregator-feeds.xml"
tempdir="$(mktemp -d -t fetchfeeds)"
TIDY="/usr/local/bin/tidy"
DISPATCHER="/home/erika/bin/dispatcher.sh"
FETCH="/usr/bin/fetch"
FETCHTHREADS=5
DISPATCHCHUNK=30
#
#mkdir -p ${tempdir}
rm -f "$akregatorFeeds"
qdbus org.kde.akregator /Akregator org.kde.akregator.part.exportFile "$akregatorFeeds"
if ! [ -f "$akregatorFeeds" ]
then
echo akregator feeds could not be retrieved via qdbus
echo exiting.
exit 1
fi
cd "$tempdir"
echo fetching each feed
for i in $(cat "$akregatorFeeds")
do
if [ $(echo $i|grep -c xmlUrl) -eq 1 ]
then
tmp=${i//xmlUrl=\"/}
xmlUrl[${#xmlUrl[@]}]=${tmp//\"/}
# echo ${xmlUrl[${#xmlUrl[@]}-1]}
fi
done
# fetch $FETCHTHREADS feeds at once
for ((i=0;i ${tempdir}/$i-tidy.xml 2>/dev/null
curcount+=1
} &
if [[ $curcount -ge $FETCHTHREADS ]]
then
curcount=0
wait
fi
done
wait
echo fetching articles
linklist=( $(cat *tidy*|grep -e /link -e /id -e /guid |grep "http.*://"|sed -e 's/\//' -e 's/\//' -e 's/\//' -e 's/\//' |grep -v feedburner|grep -v href|grep -v guid) )
for ((i=0;i<${#linklist[@]};i+=$DISPATCHCHUNK))
do
thisCHUNK=""
for ((a=$i;a/dev/null
done
# $DISPATCHER -c "$FETCH -q" -p $FETCHTHREADS --- ${thisCHUNK}
# $DISPATCHER -c "wwwoffle -O " -p $FETCHTHREADS --- ${thisCHUNK}
done
echo going online
wwwoffle -on
wwwoffle -fetch >/dev/null
rm -rf "$tempdir
Awesome Windowmanager
Februar 25, 2009
The other day I found a new windowmanager.
It is tiling and it is awesome. So to not lose the wiki and homepage here it is:
Ricoh Card Reader in Samsung q35 on FreeBSD II
Januar 8, 2009
This Cardreader works on 7.1-rc2 when used with the driver for mmc and sdhci from mav
http://people.freebsd.org/~mav/sdhci
Also the code from current for mmcsd is needed. I checked out the code from one of the cvs servers (see freebsd handbook staying up to date with -current) using cvs and changed all calls from kproc_create and kproc_exit to kthread_create and kthread_exit.
I ran kldload mmc sdhci mmcsd, inserted an SD card and watched the device nodes appear!
The Speed is comparable to the Linux/Windows driver on my machine and the solution is much more elegant than what I posted before.
Ricoh Card Reader in Samsung q35 on FreeBSD
Januar 3, 2009
Since the hack from http://lists.freebsd.org/pipermail/freebsd-mobile/2007-January/009481.html does not compile on my amd64 freebsd 7.1-rc2 I wrote a quick hack to make it compile.
From a quick glance at the code there seems to be no write support and read support is dead slow – around 30 Bytes/s. Yet, it is possible to get some pictures from an sd card.
To compile the code, folow the instructions from above mail and apply this patch:
If anyone can tell me how to properly attach ascii files to a post on wordpress.com I would be very glad. Until then I guess everyone has to live with crappy layout of the code tags
--- ../sdhcidd-0.0.3/sdhci.c 2009-01-03 01:09:30.000000000 +0100
+++ sdhci.c 2009-01-03 14:02:24.000000000 +0100
@@ -921,7 +921,7 @@
}
/* setup ISR to IRQ */
- if ( bus_setup_intr(dev,sc->irqres,INTR_TYPE_CAM|INTR_MPSAFE,NULL,(driver_intr_t *) sdhciISR,sc,&(sc->irqhnd)) )
+ if ( bus_setup_intr(dev,sc->irqres,INTR_TYPE_CAM|INTR_MPSAFE,(driver_intr_t *) sdhciISR,sc,&(sc->irqhnd)) )
{
printf("ISR setup failed.\n");
bus_release_resource(dev, SYS_RES_MEMORY, sc->portid, sc->portres);
@@ -938,7 +938,7 @@
bus_space_write_2(sc->bt,sc->bh,SDHREG_INT_STATUS_ENABLE,(SDHBIT_INT_CARD_REMOVE|SDHBIT_INT_CARD_INSERT|SDHBIT_INT_TRNCOMPLETE|SDHBIT_INT_CMDCOMPLETE|SDHBIT_INT_READ_READY|SDHBIT_INT_WRITE_READY));
bus_space_write_2(sc->bt,sc->bh,SDHREG_INT_SIG_ENABLE,(SDHBIT_INT_CARD_REMOVE|SDHBIT_INT_CARD_INSERT));
- device_printf(dev,"%s, slots=0x%x, first-slot@BAR=0x%x, revision=0x%x, interface-code=0x%x, sub-class=0x%x, basic-class=0x%x, bus-tag=0x%x, bus-hnd=0x%x\n",device_get_desc(sc->sdhci_dev),sc->slots,sc->firstBARat,rev,ic,subcls,bascls,(unsigned int)sc->bt,(unsigned int)sc->bh);
+ device_printf(dev,"%s, slots=0x%x, first-slot@BAR=0x%x, revision=0x%x, interface-code=0x%x, sub-class=0x%x, basic-class=0x%x, bus-tag=0x%x, bus-hnd=0x%x\n",device_get_desc(sc->sdhci_dev),sc->slots,sc->firstBARat,rev,ic,subcls,bascls,sc->bt,sc->bh);
sdhci_led_off(sc);
return (0);
Subversion + Unison
Dezember 2, 2008
Unison is a great tool to keep data from different folders in sync. The only drawback is, that is upsets svn if its database gets changed by an external tool like unison.
The solution is to have svn Directories excluded from the unison sync, but how to do it if these directories continually change?
This is possible using a script I wrote recently. Rename the file to .sh and review before running it.
It is still horribly inefficient but it works and since
the main time consuming factor is not the logic but IO I kept unoptimized.
FreeBSD Custom Kernel
November 26, 2008
So this is probably a newbie-mistake but anyways. If one happens to build a custom kernel in FreeBSD, then sets some variables in /boot/loader.conf that are incompatible with the standard kernel (raising vm.kmem_size_max above 700M comes to mind on 32 bit systems) and then performs an update of freebsd to the next release, then you are in trouble because the update seems to overwrite the own custom kernel. This means that a kernel will be installed that cannot cope with the custom settings from loader.conf which will cause it to crap out.
Note to self: Rebuild custom kernel after System upgrade and BEFORE reboot
Getting rid of need for TICKET_MODIFY Rights to assign tickets to trac user in dropdown box
November 24, 2008
Today I wanted to be able to assign tickets to users in trac 0.10 that do not have TICKET_MODIFY rights.
Nevertheless I wanted to be able to use the dropdown field instead of typing every username.
So I hacked trac to not require this right anymore. In api.py which on my system is located in /usr/lib/python2.4/site-packages/trac/ticket I changed line 105 to a comment
The part of the script now looks like:
# Owner field, can be text or drop-down depending on configuration
field = {'name': 'owner', 'label': 'Owner'}
if self.restrict_owner:
field['type'] = 'select'
users = []
perm = PermissionSystem(self.env)
for username, name, email in self.env.get_known_users(db):
# if perm.get_user_permissions(username).get('TICKET_MODIFY'):
users.append(username)
field['options'] = users
field['optional'] = True
else:
FreeBSD + ZFS
Oktober 22, 2008
So zfs is a wonderful filesystem. After having used it on linux with zfs-fuse I felt that it was worth using, but that it is way too slow (both for 32 and 64 bit Systems) and unstable to be used comfortably in Linux. So ZFS was one of the main reasons I switched to FreeBSD.
Installing zfs is not hard on freebsd and I do not want to go over it here. There are several Tuning guides out there and until yesterday I was too lazy to build my own kernel to increase in-kernel memory.
I had some crashes and yesterday I finally rebuilt the kernel to set options KVA_PAGES=512 in the config file to be able to increase vm.kmem_size above 700 MB. vm.kmem_size as well as vm.kmem_size_max are set to 1280MB – I have 3gb ram on my 32 bit system.
This seems to have been the Problem because since then even after heavy IO the system is stable.
postfix + relay
Oktober 16, 2008
since I went to a gpg key signing party at MOST I wanted to use caff/signing-party.
But how to deal with caff sending emails that get bounced by spamfilters to my local postfix?
The solution is to use a webmail account for sending the emails and having postfix relay local mails to one user authenticating against the smtp server of the webmailer.
Since I use gmx, I ran into this howto that does besides other things contain all the needed information to set up mail relay for postfix on the example of gmx.
http://www.contentschmiede.de/archiv/2005/08/26/postfix_fuer_typo3_und_gmx_fit_machen/
The only thing that you have to remember is: Run postmaster on all files mentioned in the tutorial except main.cf and master.cf