# bluetooth proximity detection?

## Xamindar

My friend mentioned to me that someone he knew had his gentoo set up to detect his bluetooth phone and log him in to his computer when he was in range.  I did a few searches but couldn't find any resources in these forums.

Has anyone done this?  I was thinking it would be fun to mess around with, maybe even have my computer announce when I get home.

I found a thing called Asterisk@Home that does kind of what I want, I just don't want the phone forawrding stuff.

----------

## beatryder

you might want to have a look at this:

http://pam.0xdef.net/

https://forums.gentoo.org/viewtopic-t-305540-highlight-.html

----------

## Xamindar

Hey thanks for the links.  That points me in the right direction.  Unfortunately, neither of those two options work.  I got them all set up and configured but when one or the other is enabled I can not log in at all.

I also found http://perl.jonallen.info/projects/bluetooth

which seems usefull but I haven't tried it yet.

----------

## beatryder

How are you configuring pam_blue?

I just finished fighting with pam_usb so I have become somewhat familiar with it. If you don't mind posting your configs here. Perhaps I could help you?

----------

## Xamindar

There isn't much documentation on it.  This is what I have in the "/etc/security/bluescan.conf" file.

```

###########################################################

#

#   sample bluescan.conf configuration file

#   $Id: sample.conf 3 2004-04-18 23:32:18Z pfeifer $

#

###########################################################

general {

    # the normal timeout for scanning

    # watch out for a to tiny timeslot for scanning

    # values between 4 and 15 seconds are valid

    timeout = 4;

}

xamindar = {

    # bluetooth device name

    name    = Jared`s LG CU500;

    # bluetooth mac address

    bluemac = 00:12:56:5A:92:59;

    # a seaparate timeout

    timeout = 10;

}

```

Also, a question about pam_usb.  In the logs it keeps spitting out: 

```

[device.c:74] Directory /proc/scsi/usb-storage-0/ not found

[pam.c:198] Device not valid.

[pam.c:138] Searching the utmp entry for tty tty2...

[pam.c:152] Authentication request from tty2 ()

[device.c:74] Directory /proc/scsi/usb-storage-0/ not found

[pam.c:198] Device not valid.

[pam.c:138] Searching the utmp entry for tty tty2...

[pam.c:152] Authentication request from tty2 ()

[device.c:74] Directory /proc/scsi/usb-storage-0/ not found

[pam.c:198] Device not valid.

```

Shouldn't it be looking for "/proc/scsi/usb-storage/0" instead?

----------

## beatryder

Hmm, I dunno. You should be using pam_blue though, not pam_usb...

This is what my pam config, I am currently only using pam_usb but you may want to have something similar to this with pam_blue. Obviously you will have to use different parameters.

 *Quote:*   

> Osiris ryan # cat /etc/pam.d/system-auth
> 
> #%PAM-1.0
> 
> auth       required     pam_env.so
> ...

 

----------

## Xamindar

Here is my /etc/pam.d/system-auth at the moment

```
#%PAM-1.0

#added by me

#auth       required     /lib/security/pam_blue.so debug

#auth       required     pam_usb.so force_device=/dev/sda1  fs=vfat check_if_mounted=1 debug=1 log_file=/var/log/pam_usb.log

## possible uses

# 1. Unique

# auth required pam_usb.so

# 2. Alternative

# auth sufficient pam_usb.so

# 3. Additional

# auth required pam_usb.so

auth       required     pam_env.so

auth       sufficient   pam_unix.so likeauth nullok

auth       required     pam_deny.so

account    required     pam_unix.so

password   required     pam_cracklib.so difok=2 minlen=8 dcredit=2 ocredit=2 retry=3

password   sufficient   pam_unix.so nullok md5 shadow use_authtok

password   required     pam_deny.so

session    required     pam_limits.so

session    required     pam_unix.so

```

Thanks for the help.  I guess I'll just mess around with it and hopefully figure out what's wrong.

----------

## beatryder

 *Quote:*   

> #auth       required     /lib/security/pam_blue.so debug 
> 
> #auth       required     pam_usb.so force_device=/dev/sda1  fs=vfat check_if_mounted=1 debug=1 log_file=/var/log/pam_usb.log

 

Are those commented out by default? Also I found that I had better luck getting the pam_usb to work when I did not specify the "force_device=" once i got it working (pam_usb tries sd* when not force_device is not set) I set up a udev rule to make life easier.

One thing I would suggest trying is this:

change

 *Quote:*   

> #auth       required     /lib/security/pam_blue.so debug

 

to

 *Quote:*   

> auth       [bold]sufficient[/bold]     pam_blue.so debug

 

Setting that as sufficient and placing it above the line containing "pam_unix.so" will set it such that all you need to do is enter your user name, and if the pam_blue auth works you will be logged in. Try this at a TTY

(ie: ctrl+alt+F1) if it does not, then you will still be able to login with your password. Then once you get it all working you can change it back to required.

I am gonna play with pam_blue next weekend (no time now, work/school/gf), if I get it working I will post my config and some troubleshooting tips if I have any.

----------

## Xamindar

They are commented because they don't work.

using sufficient is a good tip.  I originally had that but nothing changed so I tried using required and then I couldn't log in at all.  So at least I now know that the thing is doing *SOMETHING*.  I look forward to finding out if you are able to get it working.  I will keep on it and post if I have any success.

----------

## Xamindar

OK, my log is saying things such as this when I try to log in.

```
Sep 24 00:37:16 [pam_blue] Can't parse configuration file [_+__�!��_____]!/etc/security/bluesscan.conf

```

I went through the config file and removed all comments and made it as clean as I could but it still does that.  Anyone have any ideas?

----------

## Xamindar

Eh, I guess it's time for bed.  I tried creating a simple script to announce when I came in but even that doesn't work.

```
#!/bin/bash

ANNOUNCE=/home/xamindar/hello.txt

GOODBYE=/home/xamindar/bye.txt

HOME=`hcitool scan | grep -c 00:12:56:5A:92:59`

if [ "$HOME" == "1" ]; then

     festival --tts $ANNOUNCE

fi

if [ "$HOME" == "0" ]; then

     festival --tts $GOODBYE

fi

```

fextival spits out the following in the console:

```
xamindar@lain ~/Desktop $ ./home_announce.sh

1/.esd_auth: No such file or directory

ESD: error writing - Bad file descriptor

```

What a frustrating night.

----------

## beatryder

Check the permissions on the config file.

----------

## Xamindar

 *beatryder wrote:*   

> Check the permissions on the config file.

 

I tried making it world everything and it still did it.  Oh well.  It must be outdated.

----------

## beatryder

Have you tried contacting the original developer?

----------

## Xamindar

Yeah, I sent an email to him.  We'll see.  I did end up getting a fun little script working that will welcome me home when I enter my room with my phone.  Used flite instead of stupid festival and it worked.  So I'm content with that for now.  I'll mess around with bash scripting in the next week and try to make something more usefull.

And I did finally get the usb authentication working.  Thanks to your suggestions.  Nice to be able to plug it in and not need a password to login.

----------

## jcbray

is there an ebuild for pam blue? i couldn't find one...I did see the manual download from the link, but an ebuild is always easier!

EDIT: Nevermind, I went ahead and just did it manually...can't get it to work either  :Razz: 

----------

## Xamindar

 *jcbray wrote:*   

> is there an ebuild for pam blue? i couldn't find one...I did see the manual download from the link, but an ebuild is always easier!
> 
> EDIT: Nevermind, I went ahead and just did it manually...can't get it to work either 

 

Do you get the same errors in your everything log as I do?  Something about not being able to parse the config?

----------

## jcbray

yup!

```
Sep 26 03:47:17 localhost pam_blue[15885]: Can't parse configuration file [XÀ   »ÊMÐ   ]!/etc/security/bluesscan.conf
```

 The documentation for this isn't great, been trying to set up an sms system too, not having much luck there either though.

----------

## lkraav

do you guys have any special characters in your usernames?

i'm finding pam_blue-0.9.0 can't parse a configuration file with username "anna-maria".

----------

