Welcome to my website. I am always posting links to photo albums, art, technology and other creations. Everything that you will see on my numerous personal sites is powered by the formVistaTM Website Management Engine.

icon.linkedin.jpgicon.twitter.jpg

  • Subscribe to this RSS Feed
  • Creating a Samba Share and Configuring an Access Control List for a Shared Directory Under Linux
    10/18/2015 5:08AM

    Often administrators would like to configure a Samba share that enables users to have the same access to any files within the share.  Without some additional configuration, directories and files created by one user will not have the r/w permissions for other users that have access to that same share.

    The end goal is to have a Samba share in which any new files are created with r/w permissions for a specific group to which all of the members of the share belong.

    The first step is to determine whether the current running kernel supports ACL.  To do this we check the configuration file that was used to build the kernel, looking for config keys that contain the string 'POSIX_ACL'.

    Determine the version of your current kernel

    # uname -a
    Linux leviathan 2.6.32-358.2.1.el6.x86_64 #1 SMP Wed Mar 13 00:26:49 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

    Then grep the config file for your kernel

    # grep POSIX_ACL /boot/config-2.6.32-358.2.1.el6.x86_64
    CONFIG_EXT2_FS_POSIX_ACL=y
    CONFIG_EXT3_FS_POSIX_ACL=y
    CONFIG_EXT4_FS_POSIX_ACL=y
    CONFIG_FS_POSIX_ACL=y
    CONFIG_XFS_POSIX_ACL=y
    CONFIG_BTRFS_FS_POSIX_ACL=y
    CONFIG_TMPFS_POSIX_ACL=y
    CONFIG_JFFS2_FS_POSIX_ACL=y

    If the configuration for the filesystem type that you are using on the disk on which you want to configure the share indicates 'y', then you can continue to the next step.  If not, you will need to recompile your kernel with ACL support.

    Next, check the configuration entry in /etc/fstab for the filesystem that we want to use.

    /dev/sda1               /usr/local2/            ext3    defaults        1 2

    In this case, our filesystem is not yet configured to use acl as it is not noted after the 'defaults' option.

    Edit /etc/fstab and change that option to read 'defaults,acl' as follows:

    /dev/sda1               /usr/local2/            ext3    defaults,acl        1 2

    Unmount, and then re-mount the filesystem.

    Next, ensure that you already have a group configured for the users in question and that those users belong to that group.  For this example our group will be 'sharegroup'

    Then, create the directory that you want to share via Samba and set the permissins and acl for it.

    # mkdir /usr/local2/share

    Change the group ownership, permissions, and set the sgid flag.

    # chgrp sharegroup /usr/local2/share

    # chmod g+w share

    # chmod g+x share

    # chmod g+s share

    Now we set the acl for the directory.  The following sets the default group to 'sharegroup' with permissions of 'rwx'.

    # setfacl -m d:g:sharegroup:rwx share/

    The last thing to do is to set up the share in Samba.  Edit /etc/samba/smb.conf

    [share]
            comment =  Shared Directory
            path = /usr/local2/share
            valid users = user1 user2
            browseable = yes
            writeable = yes
            create mask = 2664
            directory mask = 2775

    The key configurations are the create and directory mask which will ensure that files are created with the proper group permissions to enable all of the users the desired access.

    Restart samba and you are finished.

    If you copy an existing directory into the share directory you will need to modify the permissions so that it is available to all of the users who have access to that share.

    Add sgid permissions to all of the sub directories:

    # find ./new_dir -type d -exec chmod g+s {} \;

    Add executable permissions for the group to all of the sub directories:

    # find ./new_dir -type d -exec chmod g+x {} \;

    Add write permissions to all files and directories in the new dir:

    # chmod -R g+w ./new_dir




  • Updating all of the pom.xml Version Numbers in a Multi-Module Maven Project
    10/13/2015 5:05PM

    To update the versions of all of the poms in a multiple module project use the versions-maven plugin.

    To update

    $ mvn versions:set -DnewVersion=1.4.0-SNAPSHOT

    Will modify all of the versions of each of the poms to the version specified.  It will create a pom.xml.versionsBackup for each pom file that it modified.  You can then examine each to make sure that it is as you intended.

    If you want, you can revert your change with

    $ mvn versions:revert

    If you are satisfied with the change, you can commit the change with

    $mvn versions:commit

  • Use awk to Print from nth element to the End of the Line
    09/15/2015 5:03PM

    If you want to extract from the nth token to the end of the line, following is how you can do that with awk:

    Given a source file with the following:

    line1 -- 01   0011 1
    line2 -- 01   0011 2
    line3 -- 01   0011 3
    line4 -- 01   0011 4
    line5 -- 01   0011 5
    line6 -- 01   0011 6
    line7 -- 01   0011 7
    line8 -- 01   0011 8
    line9 -- 01   0011 9
    line10 -- 01   0011 10

    If you want remove the 1st, 2nd, and 3rd items from the list, you can use awk to set those fields to an empty value as follows

    awk '{$1=$2=$3=""; print $0}' test.out

    Which will result in:

       value1 00 0011 1
       value2 00 0011 2
       value3 00 0011 3
       value4 00 0011 4
       value5 00 0011 5
       value6 00 0011 6
       value7 00 0011 7
       value8 00 0011 8
       value9 00 0011 9
       value10 00 0011 10

  • JVM Option for Increasing the Default Number of Lines in the StackTrace
    09/11/2015 2:27PM

    By default (Java 1.6 or greater), the JVM will output, at most, 1024 lines of the stack trace.

    In the situation where you have some recursion problem or some infinite loop that results in a stack overflow error you will need to increase this value with a JVM option to see the origin of your crash.

    To do so, add the following option to the java command

    $ java -XX:MaxJavaStackTraceDepth=-1 -jar some.jar some.package.Class  etc, etc,

    -1 indicates no limit.  Any positive integer indicates the limit to the number of lines in the stack trace.  0 means exactly what it means and will output 0 lines.

    A great resource for java options.

  • Debugging Maven Tests by Connecting an IDE to the Maven JVM
    09/10/2015 1:50PM

    In some instances you cannot reproduce a failure or condition running a test in an IDE that manifests itself when you run it on your build server or via maven on the command line.

    In that case, it is very helpful to be able to remotely attach your IDE to the running maven process and then step through the code.

    To do so you will need to:

    Execute maven on  the command line as follows (adding any additional -D args as required by your project):

    $ mvn -Dmaven.surefire.debug test -pl module-in-question

    This will run the maven automatically pausing the JVM awaiting for a remote debugger to connect to port 5005.  If you want to have it listen on a different port you can pass it in as follows:

    $ mvn -Dmaven.surefire.debug="-Xdebug  -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8081 -Xnoagent -Djava.compiler=NONE" test -pl module-in-question

    Create a debugging run profile in either Eclipse or IntelliJ or your favorite IDE configured to connect to a JVM listening on the specified port.

    Then once you have run maven on the command line, simply execute the run configuration in your IDE and debug your application as usual.

    If need be, you can run the maven JVM on the cli such that maven does not fork the tests as follows:

    $ mvnDebug -DforkCount=0 test


Advanced Search

Categories

Archives