[Bash] Automated symlinking question

Hey all, I've been struggling getting a tedious task of recreating symlinks automated... Let me justgive you an example of what I'd be doing by hand:
[~/.icons/my-theme/scalable/apps/ $] ls -l
total 8464
-rw-r--r-- 1 rob rob 3781 2008-06-05 12:08 abiword.svg
lrwxrwxrwx 1 rob rob 37 2009-05-31 16:59 access.svg -> preferences-desktop-accessibility.svg
-rwxrwxrwx 1 rob rob 43384 2009-03-29 13:00 accessories-calculator.svg
-rwxrwxrwx 1 rob rob 11145 2009-03-29 13:00 accessories-character-map.svg
-rw-r--r-- 1 rob rob 15667 2009-03-29 13:00 accessories-dictionary.svg
-rwxrwxrwx 1 rob rob 37368 2009-03-29 13:00 accessories-text-editor.svg
lrwxrwxrwx 1 rob rob 16 2009-05-30 18:29 acroread.svg -> adobe-reader.svg
lrwxrwxrwx 1 rob rob 38 2009-06-07 00:31 addressbook.svg -> ../mimetypes/x-office-address-book.svg
-rwxrwxrwx 1 rob rob 8885 2009-03-17 19:04 adobe-reader.svg
-rwxrwxrwx 1 rob rob 63899 2009-03-17 19:04 agave.svg
-rwxrwxrwx 1 rob rob 27652 2009-03-17 19:04 alacarte.svg
-rw-r--r-- 1 rob rob 9626 2008-06-05 12:08 amarok.svg
lrwxrwxrwx 1 rob rob 10 2009-05-30 18:55 amsn.svg -> im-msn.svg
-rw-r--r-- 1 rob rob 22315 2008-06-28 23:14 amule.svg
-rwxr-xr-x 1 rob rob 524008 2009-02-18 13:23 applets-screenshooter.svg
-rw-r--r-- 1 rob rob 15346 2008-08-06 21:00 application-default-icon.svg
-rwxrwxrwx 1 rob rob 12422 2009-03-17 19:04 appointment.svg
-rwxrwxrwx 1 rob rob 9381 2009-03-17 19:04 apport.svg
-rw-r--r-- 1 rob rob 43011 2008-07-31 23:30 aptoncd.svg
-rw-r--r-- 1 rob rob 21049 2008-06-05 11:42 ardour.svg
lrwxrwxrwx 1 rob rob 8 2009-05-31 21:31 audacious.svg -> xmms.svg
lrwxrwxrwx 1 rob rob 13 2009-09-25 12:25 audacious2.svg -> audacious.svg
-rw-r--r-- 1 rob rob 32781 2008-06-05 12:08 audacity.svg
-rwx------ 1 rob rob 8232 2009-03-21 09:24 audio-player.svg
-rw-r--r-- 1 rob rob 22008 2008-06-05 12:08 avant-window-navigator.svg
lrwxrwxrwx 1 rob rob 9 2009-05-30 20:08 avidemux.svg -> video.svg
-rw-r--r-- 1 rob rob 30860 2008-10-25 17:31 azureus.svg
... etc
Now I would cd ../../32x32/apps/ and then
ln -s preferences-desktop-accessibility.png access.png
ln -s adobe-reader.png acroread.png
ln -s ../mimetypes/x-office-address-book.png addressbook.png
ln -s im-msn.png amsn.png
ln -s xmms.png audacious.png
ln -s audacious.png audacious2.png
ln -s video.png avidemux.png
... etc
Notice how the extention has changed from .svg to .png
Now I would like this to be automated through some sort of bash script (any scripting language will do really).
I've tried getting this done, I just really have no clue when using bash. I realise we should probably write a script in the 32x32/apps/ folder that calls `ls -l ../../scalable/apps` and then works some magic, this I've failed at though.
Could someone please help me? This is such a tedious task to do by hand...

I'd use perl and work from the text you get from ls -l. Bit low tech, but it should work.
1. ls -l ~/.icons/my-theme/scalable/apps/ > dirlisting
2. write perl script that extracts the (source, target) pairs of the links. The main loop should be something like
while <dirlisting> {
next unless /^l/;
if (/ (\S+)\.svg -> (\S+)\.svg/) {
print "linking $1 to $2\n";
system ("ln -s $1.png $2.png");
3. run that script in all the directories where you want to create the symlinks.

Similar Messages

  • CMC Automating Reports Question

    Greetings and thanks for taking the time to look this over,
    I am looking to automate reports in CMC but cannot find a step-by-step guide to do this successfully. Can anyone provide me with directions? If not, here's the problem:
    1: When I import a Crystal report and set it to schedule, with an output of PDF and make that schedule reoccurring - the report does not run. The only reoccurring report that is successfully running is one set to reoccur "now."
    Does anyone have any suggestions?
    Thanks.

    The version reported in the "about" area is: Product: 12.0 © 2007 Business Objects
    I am attempting to schedule specific uploaded crystal reports to run on a daily, weekly, or monthly basis. This would seem pretty self explanatory, but somehow it's not working. Here's what I do now:
    1: Inside the "Automated Reports" folder, I've created subfolders for the various companies that we report for.
    2: I've created various user names for each of those companies. For example: The "Blue Company" folder has a "Blue Company" user name.
    3: I upload the Crystal Report in question into the "Blue Company" folder.
    4: I go into "properties" for the report.
    5: In "default settings", I schedule the recurrence for "Daily" with Days(N) = 1, and the start Date/Time with Today's date and the time at 2:00 AM, with an end date 10 years in the future.
    6: I try "Scheduling For" either myself or the username created in step 2.
    7: Format is changed to PDF.
    8: Destination: Changed to Email. From is set from a company email address. To are other confirmed email addresses. Subject is something like "%SI_NAME%%SI_STARTTIME%" and the Specific Name of something like "%SI_NAME%%SI_STARTTIME%.%EXT%"
    9: I then Save the report.
    I don't see any other steps to take to force the report schedule to take. If I run these reports "now," they usually run fine, but the recurrence part just refuses to work.
    Does this provide you with enough information?

  • Automator workflow question?

    I tried to create a workflow in automator but I had no luck so far. So I need some help to create an automator workflow for;
    go to a specific web page and save the page as pdf to desktop and than close the safari.
    I've tried as "record/watch what I do" in automator but when I click on the safari on dock the "watch me" script misses it and presses mail.app
    Help please. Thanks in advance.

    Give this one a try - it uses a *Run AppleScript* action to script Safari's print dialog:
    1) *Get Specified URLs* (drag URL here - only the last one will be saved)
    2) *Display Webpages*
    3) *Run AppleScript*: <pre style="</div>
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 680px; height: 340px;
    color: #000000;
    background-color: #DAFFB6;
    overflow: auto;"
    title="this text can be pasted into the AppleScript Editor">
    on run {input, parameters} -- save the current Safari page as PDF
    waitForPage()
    tell application "Safari"
    tell application "System Events"
    keystroke "p" using {command down} -- activate the Print... menu item
    delay 0.25
    click menu button "PDF" of sheet 1 of window 1 of application process "Safari" -- open the PDF menu
    delay 0.25
    keystroke (ASCII character 31) -- down arrow
    keystroke (ASCII character 31) -- down arrow
    keystroke return -- activate the Save As... menu item
    delay 0.25
    keystroke return -- press the save button
    end tell
    quit
    end tell
    end run
    to waitForPage()
    delay 1
    repeat
    tell application "Safari" to set windowName to the name of window 1
    if windowName does not contain "Untitled" then exit repeat
    delay 1
    end repeat
    repeat
    tell application "Safari" to set windowName to the name of window 1
    if windowName does not contain "Loading" then exit repeat
    delay 1
    end repeat
    repeat
    tell application "Safari" to do JavaScript "document.readyState" in document 1
    if result is "Complete" then exit repeat
    delay 1
    end repeat
    end waitForPage
    </pre>

  • [Solved] - Bash scripting - variable question.

    Hi!
    I have a little problem, I want to get data from a variable, but the variable-name that I want to
    get the data from is constructed by another variable.
    Let me explain with a little non-working example:
    test1="data1"
    test2="data2"
    test3="data3"
    for i in {1..3};do
    echo value=$[test$i];done
    I want to get the output of this code to be:
    value=data1
    value=data2
    value=data3
    and I cannot use arrays in the script I'm working on. I know how to do this in other languages
    but cannot figure it out how to do it in bash.
    Please help!
    Last edited by JSHN (2009-10-06 19:55:15)

    you need the eval command to finish how you started:
    eval echo value=\$test$i
    Otherwise, use bash arrays:
    test=('data1' 'data2' 'data3')
    for i in $(seq 0 2);do # zero-based...
    echo value=${test[$i]}
    done
    ninja-edit to remove the comma's in the array
    Last edited by klixon (2009-10-06 19:27:03)

  • Automator permissions question

    So I want to run some command-line commands to change the permissions. I know the command, but I don't know how the best way to implement them in automator. Any advice? when I try to enter them in the command-line action, it generates and error of the first command/.
    Here are the commands I need to run:
    chflags -R nouchg /Volume
    chown -R rts /Volume
    chgrp -R artserverusers /Volume
    chmod -R ur+w+x,g+r+wx,o-r-w-x /Volume
    Thanks,
    Scott

    You need to use the *do shell script* command, using administrator privileges, along with sudo. Detailed in the AppleScript Language Guide.

  • Duplicate USB drive applescript/bash/automator

    Basically i'm looking for a script that can be run whenever a usb drive is inserted. The script is to copy the contents of the usb (including the hidden files like .Trashes etc) and paste them into a folder on the desktop. It should also be able to accept any name of usb drive, basically i don't want to have to change the script each time a differently named usb is inserted. I've been looking up different scripts trying to understand it but just cannot figure out how to put different programs together to make the kind of script i need. Thanks

    You can create a folder action for this with Automator. Press the Command ( ⌘)-Spacebar keys to open the Spotlight Search field, type the first couple letters of the app name (Aut), and press the Return key.
    Press the Command ( ⌘)-N keys to open a new document and choose "Folder Action".
    With the "Library" and "Actions" buttons selected, start typing "Copy Finder Items" in the search box until it is isolated in the Action list. Drag it into the Workflow pane.
    Click "Choose folder" in the pop-up menu and click "Other...". Press the Shift-Command ( ⌘)-G keys. Type "/Volumes" and click the "Go" button. Click the "Choose" button. Choose where you want the Finder items to be saved to and whether they will be replacing existing files.
    Press the Command ( ⌘)-S keys to reveal the Save dialog, enter a name for the folder action in the text input field, and click the Save button. The folder action becomes active upon save. Your folder action is saved to /Users/<username>/Library/Workflows/Applications/Folder Actions/.
    The folder action you created will copy any volume mounted, not just USB volumes. As a result of this, and the fact that you may not want to copy all USB volumes, you need enable and disable control over the folder action. Press the Option-Command (⌘)-Spacebar keys to open a Finder window. Press the Shift-Command ( ⌘)-G keys. Type "/System/Library/CoreServices/Folder Actions Setup" and click the "Go" button.
    Drag the "Folder Actions Setup" app icon either to the Dock or the Desktop to create an alias for easy access. If you want to place an alias in the Finder sidebar, hold down the Command (⌘) key while dragging it there.
    Click the alias at any time to launch the app and open a window. To enable the folder action, select (checked) "Enable Folder Actions", "Volumes", and the workflow script you created. To disable, you can do so globally by deselecting (unchecked) "Enable Folder Actions", or individually by deselecting (unchecked) the workflow script. If you can't see your workflow, highlight "Volumes" first by clicking on it.
    You may also want to create a keyboard shortcut to launch the Folder Actions Setup app. If you navigate to  > System Preferences > Keyboard > Shortcuts > Services, under "Files and Folders" in the selection field to the right, and scroll down, you'll see there is already a service for the app. Unfortunately, if you add a shortcut for the service it will only launch when in Finder. A better solution is to create a service that can launch the app from anywhere.
    In Automator, open a new document and choose "Service".
    At the top of the Workflow pane, click the pop-up menu to the right of "Service receives", scroll down to the bottom and click "no input". Ensure that "any application" is selected in the pop-up menu to the right. Drag the "Launch Application" action into the Workflow pane. Click on the pop-up menu within that action, scroll all the way to the bottom, and click "Other". Press the Shift-Command ( ⌘)-G keys. Type "/System/Library/CoreServices/Folder Actions Setup" and click the "Go" button. Click the "Choose" button.
    Press the Command ( ⌘)-S keys to reveal the Save dialog, enter a name for the service in the text input field, and click the Save button. Your service is saved to /Users/<username>/Library/Services/.
    Navigate to  > System Preferences > Keyboard > Shortcuts > Services, and under "General" at the bottom of the selection field to the right, click on "add shortcut" to enter a unique key combination. Use your shortcut any time you want to select or desert the folder action you created.
    If you want to access your Automator service from the Menu bar, you can create an alias and place it in your Scripts Folder located at /Users/<username>/Library/Scripts/. Navigate to Script Editor > Preferences > General and select (checked) "Show Script menu in menu bar" if you don't see the Script menu in the Menu bar. You may want to deselect "Show Computer scripts".
    The workflow will run any time you choose, copy the contents of any USB, including hidden files, and paste them into a same named folder on the Desktop. Note that some USB drives, with OS install files for instance, won't copy. Be aware that the workflow will copy every volume mounted, so remember to disable the folder action when you don't want to copy.

  • Automation Settings Question

    Is there a way to have Logic automatically show all of the automation setting/parameters a plug has without having to initialize them individually by actually PICKING that parameter in the plug itself or by manually picking the plug parameter in one of the track's hidden pop up menus?
    I'll explain more specifically: Take the Channel EQ plug, for example. If I want to automate a parameter in the track's timeline (as opposed to in the Channel EQ itself) it seems I have to select that parameter in the plug first or manually select that plug in one of the track parameter's hidden pop up menus. This can get very time consuming and disrupt workflow if I want to be able to automate ANY of the plug's parameters upon selecting the plug for a track in the first place. Otherwise I have to select each one of the 40+ Channel EQ parameters manually - which can be an absolute nightmare when I'm sound designing 50+ tracks of audio - most (if not all) of which need some sort of effecting.
    Thank you all very much in advance for all the help,
    Javier Calderon

    I see your point Javier, but if I'm understanding you correctly, do you realize how many automation lanes that would be? It would be impossible to navigate through.
    Logic's automation is specifically set up this way, to avoid the utter chaos that would certainly occur if all automated parameters available were visible at the same time.
    That being said, the triangle at the bottom of the track name, when automation is visible, once clicked, will display another parameter (if automation has been written to it). I seem to vaguely remember that you could option click the triangle (or something along those lines) and have 30 "lanes" visible at the same time. Again, if automation data already had been written for those parameters.
    If this is REALLY something you want to have available, you might need to create an auto load that has ALL parameters for the all your most used plug-ins, visible, by writing a tiny bit of automation data for each and every parameter at the very top of the song. That way, those parameters would be available, and visible, if you had it saved that way.
    If I've misunderstood, my apologies.... and if there is a way to do this, and someone else knows of it specifically, I'm all ears. But it's my understanding that Logic won't make the parameter available (without you selecting it from the menu), unless automation data has been written for it. Mainly to keep things from getting out of hand, visibly speaking.

  • Thinking Home Home Automation Applescript Question

    Hello,
    I have a quick question on writing an applescript for Thinking Home 2.02. I'm just looking to do a few basic functions like turn off device "x" turn on device "y" etc. Any ideas? I looked in the dictionary for the application but I keep getting the error that it "can't get the device "b2" of controller "usb". Any ideas? Thanks again!
    tell application "Thinking Home"
    activate
    tell controller "USB"
    turn on device "B2"
    end tell
    end tell

    Looking at the dictionary, it seems that you should be using something like:
    turn on device address "B 2"
    In other words you're missing the 'address' property. Without that it is assumes you're providing a name which is more likely to be something like "Living room lamp" or "Coffee machine".

  • Automator (Newbie Question)

    Hi,
    I'm new to automator and got a free Compare Folders action from the excellent
    http://www.completedigitalphotography.com/index.php?cat=10
    website.
    I have tried dragging it in to the automator window and saving it as a finder plugin.
    I imagined that when I multi-select two folders on my desktop, right click and choose the action from the drop down it should run and tell me which are different or similar or something.
    Instead it just runs and then nothing happens, no alerts, no errors.
    Here's a link to the Action, which seems pretty useful...
    http://www.completedigitalphotography.com/Features/OtherAutomatorActions/Compare Folders.zip
    I'm sure it's that I'm not using automator correctly.
    Does anyone have a similar automator action? if so, how does one deploy it?
    Thanks,
    Tom B
    PS- If anyone knows how to delete an unwanted Finder plugin (like the ones I've created so far) that would be great too!

    Hi Tom,
    If you have selected in "Compare Folders" the option that returns files in either folder, a simple (but not ideal) solution is to put a "Run AppleScript" action next in your workflow, and paste the following in:
    on run {input, parameters}
    if the (count of the input) is greater than 0 then
    tell application "Finder"
    open the selection
    select input
    end tell
    end if
    return input
    end run
    This is not ideal because it opens both folders, and if the "Compare Folders" action returns items it found while recursing through sub-folders/bundles, then those open up in new Finder windows and the differing folder/bundle isn't highlighted. If the "Compare Folders" action returned the folders/bundles that were different, as well as their contents, then I think this could be pretty easily modified to take that into account.
    If you are using one of the options that only returns from one folder or the other, you could try this in your "Run AppleScript" action instead:
    on run {input, parameters}
    tell application "Finder"
    set theSelection to the selection
    set folder1 to item 1 of theSelection as alias
    set folder2 to item 2 of theSelection as alias
    set theSelection to (folder1 & folder2)
    set theFolder to ""
    repeat with i from 1 to the count of the input
    set theFile to item i of the input
    if theSelection contains ((the container of theFile) as alias) then
    set theFolder to ((the container of theFile) as alias)
    exit repeat
    end if
    end repeat
    if theFolder is not equal to "" then
    open theFolder
    else
    open theSelection
    end if
    select the input
    end tell
    return input
    end run
    This works best if the folders you are comparing are flat, meaning not a lot of sub-folders or bundles inside. Perhaps you could write to the author of the action and suggest that he also return the folder/bundle that differs, along with the contents?
    In any case, hopefully this gives you an idea of what you might be able to do. Hope it helps!

  • Automation test question 2011-09-22 14:29:41.889000

    This is a test. 2011-09-22 14:29:41.889000

    Hi,
    After this finding, I checked the log groups via sqldeveloper, and found that "group7" file (and it's asociate) are not displayed using this query:
    select MEMBER from gv$logfile where GROUP#=7
    (and it's associated, group_8.2722.737945377, aren't displayed if I query for the GROUP# 8)
    (Current members are displayed without a problem)
    My question: Can I delete this files safely?
    group_7
    group_8.2722.737945377If you sure that your database is not using this file. You can delete this file without problem.
    If your database is OPEN and you try to delete a file in use, you will receive the following error.
    ORA-15032: not all alterations performed
    ORA-15028: ASM file '<filename>' not dropped; currently being accessed (DBD ERROR: OCIStmtExecute)This prevents you delete files in use.
    Regards,
    Levi Pereira
    http://levipereira.wordpress.com

  • Simple Automator+Applescript Question

    EvoCam has a feature where when an event happens, such as motion, the app quits, starts, etc., it can run an AppleScript. I'd rather use automator, because it's just easier to understand for me. I wrote and automator workflow. However, as I mentioned, EvoCam only runs AppleScripts. Can someone give me an AppleScript to run an Automator workflow? I assume there is a way to run it. If not, I'll just save it as an app and have applescript run the app.
    iMac Intel Core Duo 17"   Mac OS X (10.4.8)   iPod mini 2nd Gen 4GB

    I was able to find the answer by using Script Editor's record function and then modifying the code it gave me.
    iMac Intel Core Duo 17"   Mac OS X (10.4.8)   iPod mini 2nd Gen 4GB

  • OSB automated deployment question

    Can anyone provide me a working location of import.py file for OSB 11g? The ones on Oracle.com under samples section are not working.
    Edited by: 816687 on May 12, 2011 6:42 AM

    I used the one's provide @ http://www.insemble.com/oracleservicebus-deployment.html towards the bottom of the page in Sample Download section.
    I customized the properties files for the file paths accordingly as per my directory structure.
    Hope this helps.
    Thanks,
    Patrick

  • Using bash to import/export from qt

    i have an operation i perform repeatedly and would like to write
    a bash script to do it automatically.
    what i'd like to do is:
    1. open an image sequence in qtplayer
    2. file--->export
    3. set options (like custom size, what codec)
    4. save the export as the same filename as the first file of the image sequence
    can this be done via bash?
    can anyone point me to some info on passing parameters to qtplayer via bash?
    thanks,
    BabaG

    Have you tried using Applications -> Automator -> Record and then let Automator record steps you want to do. If that works, it would be the easiest way to automate this.
    If you want to invoke the Automator script you can use the open command from within bash
    If Automator -> Record does not work for you needs, then an Applescript is the next thing you should try. If you want to invoke this from bash use the osascript command.
    Applescript questions would be best asked in the Apple Applescript forum <http://discussions.apple.com/forum.jspa?forumID=724>
    If you want/need more bash shell script questions answered, the Apple Unix forum would be the best bet <http://discussions.apple.com/forum.jspa?forumID=735>
    And while I'm mentioning the open command, you can start *QuickTime Player* with a specific file usng open
    open -a /Applications/QuickTime Player.app file.jpg
    Where file.jpg could be any file that *QuickTime Player* knows how to handle.
    Steps 2, 3, & 4 are operations that would be better handled via Automator or Applescript.

  • [SOLVED] awful.util.spawn doesn't produce correct symlinks

    I'm trying to get an automated symlinking working in awesome, which I'm invoking with:
    awful.util.spawn("ln -sfn /home/jack/source_dir/* /home/jack/dest_dir/")
    Ie I want all files and folders in /home/jack/source_dir to be symlinked to /home/jack/dest_dir.
    When I type in the code into the terminal it works as expected. When I use it in awesome with the above mentioned method though, all I get is a symlink called "*" in dest_dir, but none of the files or folders that are under source_dir.
    I tried to escape the asterisk with "\" as well,
    awful.util.spawn("ln -sfn /home/jack/source_dir/\* /home/jack/dest_dir/")
    but it didn't work.
    Does anyone have a clue what I'm missing?
    Any help would be greatly appreciated.
    Cheers
    Edit: Of course! Just a little bit more searching and it's just a case of RTFM.
    Last edited by JackH79 (2011-04-18 06:02:06)

    You know what? Haven't got the faintest. That was a long time ago and I think I was just tinkering. Seems odd to me now, but I'm sure I did have my reasons at at the time.
    Sorry that I can't be more helpful.

  • Getting to know Arch, noticed some inconsistencies

    Hi guys,
    couple of days ago I decided to try out Arch Linux for the first time.
    After installing a system, and adding a regular user I discovered I couldn't log in as a regular user from the virtual terminals, while ssh logins worked fine. After some digging, I discovered that the problem was the user's shell -- I assumed, incorrectly, that typing `which bash` would yield a valid path to bash to give to useradd(8), but it returns /usr/bin/bash, while /etc/shells lists only /bin/bash. Ok, I fixed that small problem quite easily. However, after these first impressions, questions popped up in my mind about some of the inconsistencies I noticed in the system defaults:
    1) Why is GNU bash installed as /usr/bin/bash, then symlinked as /bin/bash, while zsh gets installed directly as /bin/zsh?
    2) Why don't sshd and su (and possibly others) check if user's login shell is actually a valid shell as defined in /etc/shells?
    3) Why is some of the default /etc/pam.d/* configuration structured, but most is not? For example, what's the purpose of a config file named /etc/pam.d/system-remote-login in the base install? sshd config does not include it -- actually, no PAM config file in the base includes it.
    Last edited by vv (2013-02-03 13:01:31)

    Ok, since I got no answers to this, I decided to try and answer my own question. What puzzled me most was why is this file called /etc/pam.d/system-remote-login even there?
    Try googling for this file name. Besides Arch, you'll find that Gentoo also has a configuration file of the same name. Gentoo's /etc/pam.d/system-remote-login looks like this:
    auth include system-login
    account include system-login
    password include system-login
    session include system-login
    Feel free to can compare that with your /etc/pam.d/system-remote-login.
    I'll try and tell you what I think happened. Devs can feel free to can fill in any mistakes I made.
    There was, let's assume, a dev, I'll call him Dev1, who created the pambase Arch package. Let's assume, without meaning to insult anyone, that this developer was just a little bit lazy, or he was short on time, and copied over files from Gentoo's pambase package as a starting point. Nothing bad in not starting from scratch, this is an open source project after all.
    And Gentoo's pambase is okay-ish, I guess. It has this neat hierarchy, where, for example, you have a config file for login which adds some login(1)-specific modules, and then includes system-local-login for all four management groups that PAM provides (auth, account, password and session). system-local-login in turn, as we have seen, includes system-login for all four mgmt groups, which in turn includes system-auth, etc. Other configured local login configs, such as for logging via a DM, also include system-local-login for all mgmt groups. This design makes it easier to deploy authentication changes across all configuration -- if we would want to add a new login module for all login types, we could simply add it to system-login. A mechanism for having easy separation of local and remote login config is provided, via system-{local,remote}-login files, but it is not yet used, both files are exactly the same.
    If you take a look at Arch's /etc/pam.d/, you'll see that it uses this same design.
    Let's further assume that Dev1 did not provide /etc/pam.d/sshd, and that this file is a part of openssh package. Let's call the openssh package maintainer Dev2.
    Here's Gentoo's /etc/pam.d/sshd:
    auth include system-remote-login
    account include system-remote-login
    password include system-remote-login
    session include system-remote-login
    It again follows this simple pattern -- it just includes system-remote-login, which includes system-login. So, Gentoo has no PAM modules that are specific to ssh sessions, but if such need arises, they could be simply added to this file.
    Now let's take a look at Arch's current /etc/pam.d/sshd
    #%PAM-1.0
    #auth required pam_securetty.so #Disable remote root
    auth required pam_unix.so
    auth required pam_env.so
    account required pam_nologin.so
    account required pam_unix.so
    account required pam_time.so
    password required pam_unix.so
    session required pam_unix_session.so
    session required pam_limits.so
    session optional pam_loginuid.so
    -session optional pam_ck_connector.so nox11
    -session optional pam_systemd.so
    Ouch. So much redundant stuff here! This file is not integrated at all with the rest of the PAM config from pambase! No includes, just flat listing of modules. Not nice at all. Not "streamlined" by a long shot.
    Let's assume that Dev2, who owns the openssh package and provides the /etc/pam.d/sshd could not consult Dev1 (who owns pambase) because by that time Dev1 has left the project. Dev2 didn't bother to integrate his configuration with the rest of PAM config, he just dropped a big monolitic config file for sshd into /etc/pam.d/. And he forgot to include the PAM module that checks if the user's shell is allowed via /etc/shells. He wouldn't have made this omission if he integrated his config with pambase properly, because the common config in system-login (see above) covers that.
    This had some consequences. For example, when the switch to systemd came along, devs would have had to open two separate tickets for it's pam configuration, since now that change touches both pambase and openssh packages. Furthermore, on all users' systems both packages had to be updated! This scenario would apply to any PAM config change that also affects ssh logins. In practice, for every PAM config change now you have to update the openssh package, too.
    Coincidently, Dev2 was the dev who closed my ticket regading /etc/shells. He didn't want to respond to my question about sshd logins not getting checking against /etc/shells, which is configured as a part of the package he maintains. I sent him an email, asking him to provide the answer in this open forum. He didn't answer my email. He also didn't show up on this topic, yet.
    You can draw your own conclusions about the quality of this work. But what frustrates me really is this kind of attitude. Someone asks a guy a perfectly reasonable question, regarding his own work, and he just acts as if he didn't hear it. I know the devs are volunteers so I will not comment on professionalism, but is this even adult behaviour?
    If covering dev's own ass by avoiding questions about his work is more important to him than getting shit done right for everyone's sake, then I'm not sure if he is doing the community a favor here.
    Now, let's fix this.
    First, let's remove from sshd PAM config all the modules that would eventually get loaded if system-remote-login config is included, simply by eyeballing the files that get included down the chain from system-remote-login. We narrow the list to 5 modules:
    #auth required pam_securetty.so #Disable remote root
    account required pam_time.so
    session required pam_unix_session.so
    session required pam_limits.so
    -session optional pam_ck_connector.so nox11
    Actually these are 4 modules, one is commented out. But let's say that those are sshd-specific. And now let's reference our old friend from the beginning of the story, that little file called system-remote-login to pick up the rest, and to give it, for the first time in his life on Arch repositories, and on many Arch users' hard drives, a purpose! So we get this new /etc/pam.d/sshd:
    #%PAM-1.0
    #auth required pam_securetty.so #Disable remote root
    account required pam_time.so
    session required pam_unix_session.so
    session required pam_limits.so
    -session optional pam_ck_connector.so nox11
    auth include system-remote-login
    account include system-remote-login
    password include system-remote-login
    session include system-remote-login
    Restart sshd, can I login? Yes indeed I can. Can I login after removing my shell from /etc/shells? Indeed I can not, which is the desired behavior. Say, that took about 10 minutes, all in all. (It would be nice if anyone else would be so kind to test).
    Now I wouldn't call this "streamlined" either, but it's better. It's clearer. It's more consistent. And global PAM config changes would not require updates to openssh package anymore.
    Now let's diff this against the current sshd config, call that a patch (because, as Xyne said, devs LOVE patches) and file a new ticket, this time against the openssh package. And see what happens.
    Last edited by vv (2013-02-04 06:49:00)

Maybe you are looking for