Compdigitec Labs

Apache Active Directory authentication

By admin | September 15, 2013

Add this to /etc/ldap/ldap.conf:

REFERRALS off

Then add this to a block:

 AuthLDAPBindDN "ApacheUser@example.com"
 AuthLDAPBindPassword "the password used for apache lookups"
 AuthLDAPURL "ldap://192.168.88.2:389/dc=example,dc=com?sAMAccountName?sub?(objectClass=user)" NONE

 AuthzLDAPAuthoritative off
 AuthBasicProvider ldap
 AuthType Basic
 AuthName "Please enter your computer logon (Active Directory) to enter."
 # Important, otherwise you get "(9)Bad file descriptor: Could not open password file: (null)"
 AuthUserFile /dev/null
 Require ldap-group cn=Users
 Require valid-user

Topics: Linux | 6 Comments »

Reverse proxy HTTPS with Apache

By admin | August 23, 2013

The procedure is mostly similar to the procedure with regular HTTP, but there are a few gimmicks involved here:

  1. Generate a self-signed one or purchase a SSL certificate (*.crt) for the server in question.
  2. Make sure you run ‘sudo a2enmod ssl‘ to enable SSL.
  3. Make sure you have enable the proxy module with ‘sudo a2enmod proxy‘ as well.

Below is a sample reverse HTTPS proxy configuration.

<VirtualHost *:443>
    <Proxy *>
     Order Deny,Allow
     Allow from all
    </Proxy>

 SSLEngine On
 SSLProxyEngine On
 SSLCertificateFile /etc/apache2/cert/server.crt <!-- path to your certifcate and key -->
 SSLCertificateKeyFile /etc/apache2/cert/server.key
 SSLProxyCheckPeerCN off
 SSLProxyCheckPeerExpire off
 SSLProxyCheckPeerName off

 ProxyRequests Off
 ProxyPass / https://192.168.42.3/
 ProxyPassReverse / https://192.168.42.3/
 ProxyPreserveHost On
</VirtualHost>

Replace 192.168.42.3 with the internal IP address of your server, as before (keep the http(s):// portion).

Topics: Linux | 8 Comments »

CUPS web interface not working

By admin | August 17, 2013

CUPS seems to be working fine – documents can be printed and everything seems to work fine, but the web interface at http://localhost:631/ doesn’t work, returning something like:

Firefox can’t establish a connection to the server at localhost:631.

Solution:

Open /etc/cups/cupsd.conf as root and ensure that the line:

Listen 631

Exists somewhere in the file. Then save it and close it. Finally, restart CUPS:

sudo /etc/init.d/cups restart

Then fire up your web browser and head to http://localhost:631/ and enjoy the CUPS web interface.

Topics: Linux | 7 Comments »

OpenGL acceleration in Debian/Ubuntu

By admin | June 20, 2013

Getting “Error:  couldn’t get an RGB, Double-buffered visual“?

1) Install video driver

Example:

sudo apt-get install xserver-xorg-video-intel # or whatever nvidia package for your card

2) Install OpenGL and related libraries/tools:

sudo apt-get install libgl1-mesa-dri libgl1-mesa-glx mesa-utils

3) Restart X server or restart computer:

sudo shutdown now -r

4) Test acceleration:

glxgears
glxinfo

Sample working output:

name of display: :0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
    GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap,
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer,
    GLX_OML_swap_method, GLX_SGI_swap_control, GLX_SGIS_multisample,
    GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group,
    GLX_INTEL_swap_event
client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
client glx extensions:
    GLX_ARB_create_context, GLX_ARB_create_context_profile,
    GLX_ARB_create_context_robustness, GLX_ARB_framebuffer_sRGB,
    GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context,
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_EXT_framebuffer_sRGB,
    GLX_EXT_create_context_es2_profile, GLX_MESA_copy_sub_buffer,
    GLX_MESA_multithread_makecurrent, GLX_MESA_swap_control,
    GLX_OML_swap_method, GLX_OML_sync_control, GLX_SGI_make_current_read,
    GLX_SGI_swap_control, GLX_SGI_video_sync, GLX_SGIS_multisample,
    GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group,
    GLX_EXT_texture_from_pixmap, GLX_INTEL_swap_event
GLX version: 1.4
GLX extensions:
    GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context,
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer,
    GLX_MESA_multithread_makecurrent, GLX_MESA_swap_control,
    GLX_OML_swap_method, GLX_OML_sync_control, GLX_SGI_make_current_read,
    GLX_SGI_swap_control, GLX_SGI_video_sync, GLX_SGIS_multisample,
    GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group,
    GLX_EXT_texture_from_pixmap, GLX_INTEL_swap_event
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) 915GM x86/MMX/SSE2
OpenGL version string: 1.4 Mesa 9.1.3
OpenGL extensions:
    GL_ARB_multisample, GL_EXT_abgr, GL_EXT_bgra, GL_EXT_blend_color,
    GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_copy_texture,
    GL_EXT_polygon_offset, GL_EXT_subtexture, GL_EXT_texture_object,
    GL_EXT_vertex_array, GL_EXT_compiled_vertex_array, GL_EXT_texture,
    GL_EXT_texture3D, GL_IBM_rasterpos_clip, GL_ARB_point_parameters,
    GL_EXT_draw_range_elements, GL_EXT_packed_pixels, GL_EXT_point_parameters,
    GL_EXT_rescale_normal, GL_EXT_separate_specular_color,
    GL_EXT_texture_edge_clamp, GL_SGIS_generate_mipmap,
    GL_SGIS_texture_border_clamp, GL_SGIS_texture_edge_clamp,
    GL_SGIS_texture_lod, GL_ARB_multitexture, GL_IBM_multimode_draw_arrays,
    GL_IBM_texture_mirrored_repeat, GL_3DFX_texture_compression_FXT1,
    GL_ARB_texture_cube_map, GL_ARB_texture_env_add, GL_ARB_transpose_matrix,
    GL_EXT_blend_func_separate, GL_EXT_fog_coord, GL_EXT_multi_draw_arrays,
    GL_EXT_secondary_color, GL_EXT_texture_env_add,
    GL_EXT_texture_filter_anisotropic, GL_EXT_texture_lod_bias,
    GL_INGR_blend_func_separate, GL_NV_blend_square, GL_NV_light_max_exponent,
    GL_NV_texgen_reflection, GL_NV_texture_env_combine4, GL_S3_s3tc,
    GL_SUN_multi_draw_arrays, GL_ARB_texture_border_clamp,
    GL_ARB_texture_compression, GL_EXT_framebuffer_object,
    GL_EXT_texture_compression_s3tc, GL_EXT_texture_env_combine,
    GL_EXT_texture_env_dot3, GL_MESA_window_pos, GL_NV_packed_depth_stencil,
    GL_NV_texture_rectangle, GL_ARB_depth_texture, GL_ARB_shadow,
    GL_ARB_texture_env_combine, GL_ARB_texture_env_crossbar,
    GL_ARB_texture_env_dot3, GL_ARB_texture_mirrored_repeat,
    GL_ARB_window_pos, GL_EXT_stencil_two_side, GL_EXT_texture_cube_map,
    GL_APPLE_packed_pixels, GL_APPLE_vertex_array_object, GL_ARB_draw_buffers,
    GL_ARB_fragment_program, GL_ARB_fragment_shader, GL_ARB_shader_objects,
    GL_ARB_vertex_program, GL_ARB_vertex_shader, GL_ATI_draw_buffers,
    GL_ATI_texture_env_combine3, GL_EXT_shadow_funcs, GL_EXT_stencil_wrap,
    GL_MESA_pack_invert, GL_MESA_ycbcr_texture, GL_ARB_half_float_pixel,
    GL_ARB_point_sprite, GL_ARB_shading_language_100, GL_ARB_sync,
    GL_ARB_texture_non_power_of_two, GL_ARB_vertex_buffer_object,
    GL_ATI_blend_equation_separate, GL_EXT_blend_equation_separate,
    GL_OES_read_format, GL_ARB_pixel_buffer_object, GL_ARB_texture_rectangle,
    GL_EXT_pixel_buffer_object, GL_EXT_texture_compression_dxt1,
    GL_EXT_texture_rectangle, GL_ARB_framebuffer_object,
    GL_EXT_framebuffer_blit, GL_EXT_framebuffer_multisample,
    GL_EXT_packed_depth_stencil, GL_APPLE_object_purgeable,
    GL_ARB_vertex_array_object, GL_ATI_separate_stencil,
    GL_EXT_gpu_program_parameters, GL_OES_EGL_image, GL_ARB_copy_buffer,
    GL_ARB_map_buffer_range, GL_EXT_separate_shader_objects,
    GL_ARB_ES2_compatibility, GL_ARB_debug_output,
    GL_ARB_draw_elements_base_vertex, GL_ARB_explicit_attrib_location,
    GL_ARB_provoking_vertex, GL_ARB_sampler_objects, GL_EXT_provoking_vertex,
    GL_ARB_get_program_binary, GL_ARB_robustness,
    GL_ANGLE_texture_compression_dxt3, GL_ANGLE_texture_compression_dxt5,
    GL_ARB_internalformat_query, GL_ARB_texture_storage,
    GL_ARB_invalidate_subdata

Topics: Linux | 9 Comments »

Check if an Intent can be used in Android

By admin | June 15, 2013

Intent intent = new Intent("org.openintents.action.PICK_FILE"); // or any other intent
// add other intent options here

if(context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0) {
    // we can use this intent
} else {
    // we can't use this intent
}

From: http://www.curious-creature.org/2008/12/15/android-can-i-use-this-intent/ [Romain Guy]

Topics: Mobile | 7 Comments »

Generating slope fields / direction fields with python and gnuplot

By admin | April 21, 2013

Slope field of (dy/dx) = x/y

Slope field of (dy/dx) = x/y

slopefields.py (1.9 KB)

Now you can generate your own slope field / vector field / direction field of a differential equation using open source python and gnuplot!

Topics: Linux | 9 Comments »

Techniques for testing Android fragments

By admin | March 4, 2013

How to test a fragment-based Android application:

Preferably test in the “don’t keep activities” mode, as this will root out a ton of bugs related to the Android lifecycle – i.e. when Android decides to kill an old activity of yours.

Case Study:

User complaint: http://forum.videolan.org/viewtopic.php?f=35&t=108743

The story so far… old versions of the VLC for Android beta, up to 0.0.10, suffer from a bug, where trying to delete something in another fragment causes the other (non-visible) fragment to receive the onContextItemSelected() call. After setting user visibility hints for that bug, a series of fragment related bugs appeared, mostly involving IllegalStateException in android.support.v4.app.FragmentManager because of duplicate fragments being added.

The problems were caused when Android decided to kill unused background activities. The interface code would try to recreate and re-add() fragments, even though Android had automatically recreated them via “android.support.fragments” in the onCreate() bundle. This would manifest after opening another activity, shutting the screen off, or having a system popup appear.

The solution was to keep better track of currently-added fragments, as member variables of the main activity may not necessarily be kept after the activity was hidden. To solve the problem, a check was implemented in onRestoreFragments() to ‘recall’ fragments that were already added. This fixed the problem permanently.

The moral of the story: watch and manage fragments very carefully in order to prevent problems.

Topics: Mobile | 9 Comments »

Compiling mingw-w64 with GCC 4.8

By admin | February 7, 2013

You need at least mingw-w64 rev 5579, build-essential, and a working compiler. Be sure to have installed flex and bison.

Replace the demo prefix /usr/i686-w64-mingw32 with whatever you feel like, if you want to.

Extract the gcc tarball, and pull in mpfr, mpc, and and gmp tarballs under the extracted gcc root.

sudo mkdir /usr/i686-w64-mingw32

../binutils-2.22/configure --disable-multilib --target=i686-w64-mingw32 --with-sysroot=/usr/i686-w64-mingw32 --prefix=/usr/i686-w64-mingw32
make -j4
sudo make install

ln -s /usr/i686-w64-mingw32/i686-w64-mingw32 /usr/i686-w64-mingw32/mingw

../mingw-w64/mingw-w64-headers/configure --build=i686-linux-gnu --host=i686-w64-mingw32 --prefix=/usr/i686-w64-mingw32/i686-w64-mingw32 # notice the extra i686-w64-mingw32
make
sudo make install

../gcc-4.8-20130120/configure --target=i686-w64-mingw32 --disable-multilib --enable-languages=c,c++  --with-system-zlib --enable-shared --prefix=/usr/i686-w64-mingw32 --with-sysroot=/usr/i686-w64-mingw32
make all-gcc -j4
sudo make install-gcc

../mingw-w64/configure --host=i686-w64-mingw32 --prefix=/usr/i686-w64-mingw32 --with-sysroot=/usr/i686-w64-mingw32
make -j4
sudo su
export PATH=/usr/i686-w64-mingw32/bin:$PATH
make install
exit

cd ../gcc-4.8-20130120-build
make -j4
# /usr/i686-w64-mingw32/i686-w64-mingw32/bin/ld: cannot find dllcrt2.o: No such file or directory
sudo ln -s /usr/i686-w64-mingw32/lib/dllcrt2.o /usr/i686-w64-mingw32/mingw/lib/
make
# checking for ld that supports -Wl,--gc-sections... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
# dig into i686-w64-mingw32/libstdc++-v3/config.log, you find this:
# /usr/i686-w64-mingw32/i686-w64-mingw32/bin/ld: cannot find crt2.o: No such file or directory
# solution:
sudo ln -s /usr/i686-w64-mingw32/lib/crt2.o /usr/i686-w64-mingw32/mingw/lib/
make
sudo make install

../../../mingw-w64/mingw-w64-libraries/winstorecompat/configure --prefix=/usr/i686-w64-mingw32 --host=i686-w64-mingw32
make
sudo su
export PATH=/usr/i686-w64-mingw32/bin:$PATH
make install
exit

And just for fun, let’s test it:

i686-w64-mingw32-gcc --version
# i686-w64-mingw32-gcc (GCC) 4.8.0 20130120 (experimental)
# Copyright (C) 2013 Free Software Foundation, Inc.
# This is free software; see the source for copying conditions.  There is NO
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

i686-w64-mingw32-gcc ~/c/hello.c

file a.exe
# a.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit

wine a.exe
# Hello, World!

Bibliography:

Topics: Linux | 3 Comments »

Android DTS benchmark – libavcodec vs libdca

By admin | January 4, 2013

Galaxy Nexus with Android 4.1, ARMv7+NEON, VLC for Android 0.0.9-git (libdca 0.0.5 and libav revision 53c25ee), and OpenSL ES audio output

See previous audio benchmark for method

Summary/Conclusion: On an ARMv7 processor with NEON, libavcodec is faster by about 7% CPU-wise.

libdca libavcodec
Mean 18.326% 11.193%
Median 17.7% 9.4%
Mode 17.5% 9%
DTS benchmark - libdca vs libavcodec

DTS benchmark – libdca vs libavcodec

Raw data:

===libdca===
D/VLC     (15980): [0x5c6299b4]: main decoder using decoder module "dts"
  PID  PPID USER     STAT   VSZ %MEM CPU %CPU COMMAND
15980   124 10079    R     527m 75.7   1 26.0 org.videolan.vlc
15980   124 10079    S     531m 76.4   1 21.4 org.videolan.vlc
15980   124 10079    S     531m 76.4   1 17.5 org.videolan.vlc
15980   124 10079    S     531m 76.4   1 17.6 org.videolan.vlc
15980   124 10079    S     531m 76.4   1 17.4 org.videolan.vlc
15980   124 10079    S     531m 76.4   1 18.4 org.videolan.vlc
15980   124 10079    S     531m 76.4   1 17.7 org.videolan.vlc
15980   124 10079    S     531m 76.4   0 17.5 org.videolan.vlc
15980   124 10079    S     531m 76.4   1 17.3 org.videolan.vlc
15980   124 10079    S     531m 76.4   0 17.1 org.videolan.vlc
D/VLC     (16769): [0x5bf9e44c]: main decoder using decoder module "dts"
16769   124 10079    S     524m 75.3   1 20.8 org.videolan.vlc
16769   124 10079    S     531m 76.4   1 25.0 org.videolan.vlc
16769   124 10079    S     531m 76.4   1 17.2 org.videolan.vlc
16769   124 10079    S     531m 76.4   1 17.6 org.videolan.vlc
16769   124 10079    S     531m 76.4   1 18.0 org.videolan.vlc
16769   124 10079    S     531m 76.4   1 17.7 org.videolan.vlc
16769   124 10079    S     531m 76.4   0 18.2 org.videolan.vlc
16769   124 10079    S     531m 76.4   1 17.8 org.videolan.vlc
16769   124 10079    S     531m 76.4   1 17.9 org.videolan.vlc
16769   124 10079    S     531m 76.4   0 17.5 org.videolan.vlc
D/VLC     (16840): [0x5c64fc54]: main decoder using decoder module "dts"
16840   124 10079    S     523m 75.3   0  9.3 org.videolan.vlc
16840   124 10079    S     531m 76.4   1 24.1 org.videolan.vlc
16840   124 10079    S     531m 76.4   0 17.9 org.videolan.vlc
16840   124 10079    S     531m 76.4   0 16.8 org.videolan.vlc
16840   124 10079    S     531m 76.4   1 17.7 org.videolan.vlc
16840   124 10079    S     531m 76.4   0 17.5 org.videolan.vlc
16840   124 10079    S     531m 76.4   1 17.8 org.videolan.vlc
16840   124 10079    S     531m 76.4   0 18.2 org.videolan.vlc
16840   124 10079    S     531m 76.4   1 17.7 org.videolan.vlc
16840   124 10079    S     531m 76.4   0 17.2 org.videolan.vlc

=====libavcodec=====
D/VLC     (17167): [0x5c43802c]: main decoder using decoder module "avcodec"
  PID  PPID USER     STAT   VSZ %MEM CPU %CPU COMMAND
17167   124 10079    S     523m 75.3   0 20.2 org.videolan.vlc
17167   124 10079    S     532m 76.4   0 16.0 org.videolan.vlc
17167   124 10079    S     532m 76.4   0  9.4 org.videolan.vlc
17167   124 10079    S     532m 76.4   1  8.8 org.videolan.vlc
17167   124 10079    S     532m 76.4   0  9.0 org.videolan.vlc
17167   124 10079    S     532m 76.4   1  9.3 org.videolan.vlc
17167   124 10079    S     532m 76.4   0  9.6 org.videolan.vlc
17167   124 10079    S     532m 76.4   1  9.7 org.videolan.vlc
17167   124 10079    S     532m 76.4   1  9.4 org.videolan.vlc
17167   124 10079    S     532m 76.4   0  7.9 org.videolan.vlc
D/VLC     (17276): [0x5c4add84]: main decoder using decoder module "avcodec"
17276   124 10079    S     522m 75.1   0 20.0 org.videolan.vlc
17276   124 10079    S     530m 76.2   1 14.2 org.videolan.vlc
17276   124 10079    S     530m 76.2   0  8.7 org.videolan.vlc
17276   124 10079    S     530m 76.2   0  9.4 org.videolan.vlc
17276   124 10079    S     530m 76.2   0  9.9 org.videolan.vlc
17276   124 10079    S     530m 76.2   0  9.9 org.videolan.vlc
17276   124 10079    S     530m 76.2   1  9.0 org.videolan.vlc
17276   124 10079    S     530m 76.2   0  9.2 org.videolan.vlc
17276   124 10079    S     530m 76.2   0  9.7 org.videolan.vlc
17276   124 10079    S     530m 76.2   1  9.3 org.videolan.vlc
D/VLC     (17340): [0x5c657204]: main decoder using decoder module "avcodec"
17340   124 10079    S     522m 75.1   1 27.6 org.videolan.vlc
17340   124 10079    S     530m 76.3   0 14.5 org.videolan.vlc
17340   124 10079    S     530m 76.2   0  9.5 org.videolan.vlc
17340   124 10079    S     530m 76.2   0  9.4 org.videolan.vlc
17340   124 10079    S     530m 76.2   0  9.0 org.videolan.vlc
17340   124 10079    S     530m 76.2   1  9.4 org.videolan.vlc
17340   124 10079    S     530m 76.2   0  9.0 org.videolan.vlc
17340   124 10079    S     530m 76.2   0 10.0 org.videolan.vlc
17340   124 10079    S     530m 76.2   0  9.0 org.videolan.vlc
17340   124 10079    S     530m 76.2   0  9.8 org.videolan.vlc

Topics: Mobile | 6 Comments »

Compose key not working with iBus

By admin | December 8, 2012

The iBus input method does not work with the compose key – see Debian bug #591459 and Ubuntu bug #493766. It seems that iBus is intercepting all keystrokes and substituting its own instead, even though xev shows the Multi_key and accent being produced. For example, Multi_Key + ‘ + e leads to ‘e instead of é.

A temporary solution is to export XMODIFIERS=”” to bypass iBus, freeing the keystrokes for compose. However, this disables the iBus input method as it prevents iBus from receiving the keystrokes. XMODIFIERS, however, can be set per application, so one can simply set XMODIFIERS=”” for the specific application that requires the compose key.

Topics: Linux | 6 Comments »

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles! « Older Entries Newer Entries »