HEX
Server: LiteSpeed
System: Linux 112.webhostingindonesia.co.id 5.14.0-570.62.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 10:10:59 EST 2025 x86_64
User: iyfwylsv (10313)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/fail2ban/server/__pycache__/action.cpython-39.pyc
a

�5��;���@stdZdZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZzddl
mZWney�ddlmZYn0ddlmZdd	lmZdd
lmZddlmZdd
lmZmZmZmZmZmZm Z ee!�Z"e	�#�Z$ej%Z&e�'d�Z(dZ)e�'d�Z*dd�dd�d�Z+ddd�Z,e,�-e+�Gdd�dee.�Z/Gdd�de.ed�Z0ddd�Z1Gd d!�d!e0�Z2dS)"z'Cyril Jaquier and Fail2Ban Contributorsz>Copyright (c) 2004 Cyril Jaquier, 2011-2012 Yaroslav Halchenko�GPL�N)�ABCMeta)�MutableMapping�)�
mapTag2Opt)�DNSUtils)�MyTime)�Utils�)�	getLogger�_merge_copy_dicts�
splitwords�substituteRecursiveTags�
uni_string�TAG_CRE�MAX_TAG_REPLACE_COUNTz<F-([A-Z0-9_\-]+)>)�inet4�inet6z^(\w+)\?(family)=(.*)$cCsttjdd��S)NT�Zfqdn��strrZgetHostname�rr�:/usr/lib/python3.9/site-packages/fail2ban/server/action.py�<lambda>?�rcCsttjdd��S)NFrrrrrrr@r)zfq-hostnamezsh-hostname�
� )�br�spc@s�eZdZdZdZdZdd�Zddd�Zd d
d�ZeZ	d!d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)"�
CallingMapa"A Mapping type which returns the result of callable values.

	`CallingMap` behaves similar to a standard python dictionary,
	with the exception that any values which are callable, are called
	and the result is returned as the value.
	No error handling is in place, such that any errors raised in the
	callable will raised as usual.
	Actual dictionary is stored in property `data`, and can be accessed
	to obtain original callable values.

	Attributes
	----------
	data : dict
		The dictionary data which can be accessed to obtain items uncalled
	r)�data�storage�	immutableZ
__org_datacOs"t�|_d|_t|i|��|_dS)NT)�dictr!r"r )�self�args�kwargsrrr�__init___szCallingMap.__init__TcCs2t�|_z|j|_Wnty&Yn0||_dS�N)r#r!�_CallingMap__org_datar �AttributeErrorr")r$r"rrr�resetdszCallingMap.resetFcCsd|jj|�|t�fS)Nz%s(%r))�	__class__�__name__�_asdictr)r$�
calculatedrrr�_asreprlszCallingMap._asreprNcs�t�jfi�j��}|s2t�fdd�|��D��St|���D]@\}}t|�r>z"��|�}|rf||�|||<Wq>Yq>0q>|S)Nc3s,|]$\}}t|�r|�jvr||fVqdSr()�callable�
CM_REPR_ITEMS)�.0�n�v�r$rr�	<genexpr>us
�z%CallingMap._asdict.<locals>.<genexpr>)r#r r!�items�listr1�__getitem__)r$r/Zchecker�dr4r5rr6rr.rs
zCallingMap._asdictcCs0z|j|}Wnty*|j|}Yn0|Sr()r!�KeyErrorr �r$�key�valuerrr�
getRawItem�s
zCallingMap.getRawItemcCsbz|j|}Wnty*|j|}Yn0t|�r^t|d�rN|jjrN||�n|�}||j|<|S)N�__code__)r!r<r r1�hasattrrA�co_argcountr=rrrr:�s 
zCallingMap.__getitem__cCs:|jr,|j��|_|j|_|j��|_d|_||j|<dS�NF)r"r!�copyr r)r=rrr�__setitem__�szCallingMap.__setitem__cCstd|��dS)NzKey %r was deleted)r<�r$r>rrrZ
__unavailable�szCallingMap.__unavailablecCsX|jr,|j��|_|j|_|j��|_d|_z|j|=WntyJYn0|j|=dSrD)r"r!rEr r)r<rGrrr�__delitem__�szCallingMap.__delitem__cCs
t|j�Sr()�iterr r6rrr�__iter__�szCallingMap.__iter__cCs
t|j�Sr()�lenr r6rrr�__len__�szCallingMap.__len__cCs|�t|j|j��Sr()r,rr r!r6rrrrE�szCallingMap.copy)T)F)FN)r-�
__module__�__qualname__�__doc__r2�	__slots__r'r+r0�__repr__r.r@r:rFZ_CallingMap__unavailablerHrJrLrErrrrrJs 


	
rc@sXeZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
edd��Zdd�Z
dS)�
ActionBasea�An abstract base class for actions in Fail2Ban.

	Action Base is a base definition of what methods need to be in
	place to create a Python based action for Fail2Ban. This class can
	be inherited from to ease implementation.
	Required methods:

	- __init__(jail, name)
	- start()
	- stop()
	- ban(aInfo)
	- unban(aInfo)

	Called when action is created, but before the jail/actions is
	started. This should carry out necessary methods to initialise
	the action but not "start" the action.

	Parameters
	----------
	jail : Jail
		The jail in which the action belongs to.
	name : str
		Name assigned to the action.

	Notes
	-----
	Any additional arguments specified in `jail.conf` or passed
	via `fail2ban-client` will be passed as keyword arguments.
	cCs(d}|D]}tt||d��sdSqdS)N)�start�stop�ban�reban�unbanFT)r1�getattr)�cls�C�required�methodrrr�__subclasshook__�s
zActionBase.__subclasshook__cCs"||_||_td|jj�|_dS)Nzfail2ban.%s)�_jail�_namerr,r-�_logSys�r$Zjail�namerrrr'�szActionBase.__init__cCsdS)z,Executed when the jail/action is started.
		Nrr6rrrrS�szActionBase.startcCsdS)z,Executed when the jail/action is stopped.
		Nrr6rrrrT�szActionBase.stopcCsdS)��Executed when a ban occurs.

		Parameters
		----------
		aInfo : dict
			Dictionary which includes information in relation to
			the ban.
		Nr�r$�aInforrrrU�s	zActionBase.bancCs
|�|�S)rc)rUrdrrrrVs	zActionBase.rebancCsdSrDrr6rrr�_prolongableszActionBase._prolongablecCsdS)z�Executed when a ban expires.

		Parameters
		----------
		aInfo : dict
			Dictionary which includes information in relation to
			the ban.
		NrrdrrrrWs	zActionBase.unbanN)r-rMrNrO�classmethodr]r'rSrTrUrV�propertyrfrWrrrrrR�s


rR)�	metaclass�str2seconds�ignore)�timeoutZbantimecs�eZdZdZed�Zdd�Z�fdd�Zedd��Z	d	d
�Z
e
Zdd�Ze
d
d��Ze
dd��Zdd�Zdd�Zgdfdd�Ze
dd��Ze
dd��Ze
dd��Zdd�ZdNd!d"�ZdOd$d%�Ze
d&d'��Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�ZdPd2d3�Zd4d5�Z dQd6d7�Z!e"�#d8�Z$ed9d:��Z%edRd<d=��Z&e"�#d>�Z$e"�#d?�Z'edSd@dA��Z(e
dBdC��Z)dDdE�Z*dTdGdH�Z+dUdIdJ�Z,e-dVdLdM��Z.�Z/S)W�
CommandActiona�A action which executes OS shell commands.

	This is the default type of action which Fail2Ban uses.

	Default sets all commands for actions as empty string, such
	no command is executed.

	Parameters
	----------
	jail : Jail
		The jail in which the action belongs to.
	name : str
		Name assigned to the action.

	Attributes
	----------
	actionban
	actioncheck
	actionreban
	actionreload
	actionrepair
	actionstart
	actionstop
	actionunban
	timeout
	)�matchesZ	ipmatchesZ
ipjailmatchescCsZd|_zFd|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
Wd|_nd|_0dS)z8 Clear all lists/dicts parameters (used by reloading)
		r�<�rN)�_CommandAction__initrlZactionstartZ	actionban�actionrebanZactionunban�actioncheckZactionrepairZactionflushZ
actionstopZactionreloadr6rrr�clearAllParams>szCommandAction.clearAllParamscsHtt|��||�d|_d|_i|_i|_|��|j�	d|j
�dS)Nrz
Created %s)�superrmr'rq�_CommandAction__properties�_CommandAction__started�_CommandAction__substCachertr`�debugr,ra�r,rrr'XszCommandAction.__init__cCstSr()�NotImplemented)rYrZrrrr]aszCommandAction.__subclasshook__cCsn|�d�s`|js`t|�s`t�|�}|dkr.dS|dkr@t�|�}d|_|j�	�|j
�d||�||j|<dS)N�_rkrjz
  Set %s = %r)
�
startswithrqr1�WRAP_CMD_PARAMS�getrrjrvrx�clearr`ry�__dict__)r$rbr?Zwrprrr�__setattr__es


zCommandAction.__setattr__cCs4|�d�s(d|_|j��|j�d|�|j|=dS)Nr|z
  Unset %s)r}rvrxr�r`ryr�)r$rbrrr�__delattr__ws


zCommandAction.__delattr__cs2�jdur�jSt�fdd�t��D���_�jS)z`A dictionary of the actions properties.

		This is used to substitute "tags" in the commands.
		Nc3s4|],}|�d�stt�|��s|t�|�fVqdS)r|N)r}r1rX)r3r>r6rrr7�s�z,CommandAction._properties.<locals>.<genexpr>)rvr#�dirr6rr6r�_properties�s
�
zCommandAction._propertiescCs|jSr()rxr6rrr�_substCache�szCommandAction._substCachecCsF|j||j|rd|nd|jd�}|r.d|vr2|S|�|d|i�}|S)N�family=rp��conditional�cache�<�family)�
replaceTagr�rx�replaceDynamicTags)r$�tagr��cmdrrr�
_getOperation�s
�zCommandAction._getOperationcs�d|f}t|�sLt��s,|j�|i����S�fdd�|j�|i���D�S|d}|r�z|j|}Wn ty�i}|j|<Yn0||�<nPz<|j|}|���}t|���D]\�}||kr�|�=q�Wnty�Yn0dS)z? Get, set or delete command of operation considering family.
		Z__eOpCmdcsg|]\}}�|�r|�qSrr�r3�fr5�r�rr�
<listcomp>�rz4CommandAction._operationExecuted.<locals>.<listcomp>rN)rKr1rxrr8r<�popr9)r$r�r�r%r>r�Zfamdr5rr�r�_operationExecuted�s( 


z CommandAction._operationExecutedNcsBd}d}|s dd�|j��D�}|D]��z�|�|��}d}|r�||�|�fdd��vr�|}	|jr�t|jjdd�}
|
s�|jj�d�}
t|jjd|
�t	�
�|
d	<�|
d
<|�||
�}	|�|	|j
�}||M}|r�|�|�|�|�|r�|nd�Wq$t�y}zd}|}WYd}~q$d}~00q$|�s>td||j|j|f��|S)
z�Executes the operation commands (like "actionstart", "actionstop", etc).

		Replace the tags in the action command with actions properties
		and executes the resulting command.
		TzScript errorcSsg|]\}}|r|�qSrr)r3�famoperr5rrrr��rz3CommandAction._executeOperation.<locals>.<listcomp>cs|�kSr(r)r��r�rrr�rz1CommandAction._executeOperation.<locals>.<lambda>Z
actionInfoN�timer�FzError %s action %s/%s: %r)rwr8r�r�r^rX�actionsZ_getActionInfo�setattrrr�r��
executeCmdrl�
ValueError�RuntimeErrorr_)r$r�Z	operationr��	afterExec�res�errr��ret�realCmdre�err�r�_executeOperation�s8zCommandAction._executeOperationcCsH|j�d�}|dur|Sd}|jD]}t�|�r"d}q:q"||jd<|S)NZ__hasCondSectionFT)r�r�CONDITIONAL_FAM_RE�match)r$r5r4rrr�_hasCondSection�s


zCommandAction._hasCondSectioncCsl|j�d�}|r|S|j�d�}|r<t|ttf�s<t|�}n"|jrXt�rPddgndg}ndg}||jd<|S)NZ
__familiesZfamiliesrrrp)r�r�
isinstancer9�setr
r��allowed_ipv6�r$r5rrr�	_families�s

zCommandAction._familiescCs,|j�d�}|dur|S|j}||jd<|S)z1Checks the action depends on family (conditional)Zactionstart_on_demandN)r�rr�r�rrr�_startOnDemand�s
zCommandAction._startOnDemandcCs|��S)��Executes the "actionstart" command.

		Replace the tags in the action command with actions properties
		and executes the resulting command.
		)�_startr6rrrrS	szCommandAction.startFcsZ�jr|s$dSn|s$�j�|�r$dS|dur2|gn�j}�fdd�}�jdd||d�}|S)r�TNcs |r��d|d�d�j|<dS)N�<actionstop>r)r�rw�r�r�r6rr�_startedsz&CommandAction._start.<locals>._started�
<actionstart>Zstarting�r�r�)r�rwrr�r�)r$r��
forceStartr�r�rr6rr�szCommandAction._start�<actionban>cCs`|�dd�}|jr,|j�|�s,|j|dd�|�||�sDtd|��|j�|d�dB|j|<dS)	a)Executes the given command ("actionban" or "actionreban").

		Replaces the tags in the action command with actions properties
		and ban information, and executes the resulting command.

		Parameters
		----------
		aInfo : dict
			Dictionary which includes information in relation to
			the ban.
		r�rpT�r�zError banning %(ip)sr�N)rr�rwr��_processCmdr�)r$rer�r�rrrrU%s
zCommandAction.bancCs t|d�o|jot|j���S)N�
actionprolong)rBr�r�isspacer6rrrrf;s�zCommandAction._prolongablecCs|�d|�std|��dS)aExecutes the "actionprolong" command.

		Replaces the tags in the action command with actions properties
		and ban information, and executes the resulting command.

		Parameters
		----------
		aInfo : dict
			Dictionary which includes information in relation to
			the ban.
		z<actionprolong>zError prolonging %(ip)sN)r�r�rdrrr�prolong@szCommandAction.prolongcCs:|�dd�}|j�|d�d@r6|�d|�s6td|��dS)aExecutes the "actionunban" command.

		Replaces the tags in the action command with actions properties
		and ban information, and executes the resulting command.

		Parameters
		----------
		aInfo : dict
			Dictionary which includes information in relation to
			the ban.
		r�rprr
�
<actionunban>zError unbanning %(ip)sN)rrwr�r�)r$rer�rrrrWOszCommandAction.unbancCs|�||jrdnd�S)aDExecutes the "actionreban" command if available, otherwise simply repeat "actionban".

		Replaces the tags in the action command with actions properties
		and ban information, and executes the resulting command.

		Parameters
		----------
		aInfo : dict
			Dictionary which includes information in relation to
			the ban.
		z
<actionreban>r�)rUrrrdrrrrV`s
zCommandAction.rebancs:dd��j��D�}|sdS�fdd�}�jdd||d�S)	aExecutes the "actionflush" command.
		
		Command executed in order to flush all bans at once (e. g. by stop/shutdown 
		the system), instead of unbanning of each single ticket.

		Replaces the tags in the action command with actions properties
		and executes the resulting command.
		cSs g|]\}}|d@dkr|�qS)r�rr�rrrr�yrz'CommandAction.flush.<locals>.<listcomp>Tcs&|r"�j�|�r"�j|dM<dS)N���)rwrr�r6rr�_afterFlush}sz(CommandAction.flush.<locals>._afterFlushz
<actionflush>Zflushingr�)rwr8r�)r$r�r�rr6r�flushos
zCommandAction.flushcCs|��S)��Executes the "actionstop" command.

		Replaces the tags in the action command with actions properties
		and executes the resulting command.
		)�_stopr6rrrrT�szCommandAction.stopcs||dur,dd��j��D�}|s$dSi�_n2z�j|dM<|g}Wnty\YdS0�fdd�}�jdd	||d
�S)r�NcSsg|]\}}|r|�qSrrr�rrrr��rz'CommandAction._stop.<locals>.<listcomp>Trcs|r��d|d�dS)Nr�)r�r�r6rr�_stopped�sz%CommandAction._stop.<locals>._stoppedr�Zstoppingr�)rwr8r<r�)r$r�r�rr6rr��s
zCommandAction._stopcKs|�dd�S)z�Executes the "actionreload" command.

		Parameters
		----------
		kwargs : dict
		  Currently unused, because CommandAction do not support initOpts

		Replaces the tags in the action command with actions properties
		and executes the resulting command.
		z<actionreload>Z	reloading)r�)r$r&rrr�reload�szCommandAction.reloadcCsVd}|jrRt|j���D]8\}}|r|�||�sd|j|<|�d|d�|dM}q|S)zFExecutes the invariant check with repair if expected (conditional).
		Trr�NF)rsr9rwr8�_invariantCheckr�)r$�beforeRepairr�r��startedrrr�consistencyCheck�s

zCommandAction.consistencyCheckz[\\#&;`|*?~<>^()\[\]{}$'"\n\r]cs(ddd���fdd�}|j�||�}|S)a5Escape characters which may be used for command injection.

		Parameters
		----------
		value : str
			A string of which characters will be escaped.

		Returns
		-------
		str
			`value` with certain characters escaped.

		Notes
		-----
		The following characters are escaped::

			\#&;`|*?~<>^()[]{}$'"


		r4�r)r�
cs|��}d��||�S)N�\)�groupr)�m�c�Z_map2crr�	substChar�sz*CommandAction.escapeTag.<locals>.substChar)�
ESCAPE_CRE�sub)rYr?r�rr�r�	escapeTag�s
zCommandAction.escapeTagrpcs<d|vr|S|dur:|�f}z
||WSty8Yn0t|t�}|�|s�d�}|dur�dt|��f}z||�Wnty�Yn0�dur�t|��j|d��|dur��||<tt������fdd�}	td}
t�	|	|�}|r�q&||k�s&d|v�r�q&|}|
d8}
|
dkr�t
d	|f��q�|du�r8|||<|S)
z�Replaces tags in `query` with property values.

		Parameters
		----------
		query : str
			String with tags.
		aInfo : dict
			Tags(keys) and associated values for substitution in query.

		Returns
		-------
		str
			`query` string with tags replaced.
		r�Nz
subst-tags)rk�addreplcsn|�d�}d}�r$��|d��}|durN��|�}|durN��||���St|�}|�jvrj��|�}|S)Nr�?)r�rr�_escapedTagsr��r�r�r?��ADD_REPL_TAGS_CMrYr�ZsubInforr�substVals



z*CommandAction.replaceTag.<locals>.substValrrzaunexpected too long replacement interpolation, possible self referencing definitions in query: %s)r<r�r�idrr��
ADD_REPL_TAGSrrr�r�)rY�queryrer�r�r�ZckeyZ	noRecReplZcsubkeyr��countr?rr�rr��sP


���
zCommandAction.replaceTagz![\\#&;`|*?~<>\^\(\)\[\]{}$'"\n\r]z\Wcs�t���s��fdd��tt�����fdd�}t�||�}d|vrp��d���sVi���fdd�}t�||�}�r�t�|��}|S)	a%Replaces dynamical tags in `query` with property values.

		**Important**
		-------------
		Because this tags are dynamic resp. foreign (user) input:
		  - values should be escaped (using "escape" as shell variable)
		  - no recursive substitution (no interpolation for <a<b>>)
		  - don't use cache

		Parameters
		----------
		query : str
			String with tags.
		aInfo : dict
			Tags(keys) and associated values for substitution in query.

		Returns
		-------
		str
			shell script as string or array with tags replaced (direct or as variables).
		cs2�j�|�r.d�j�d|�}|�|<d|}|S)Nzf2bV_%sr|�$)r��search�
ESCAPE_VN_CREr�)r�r?)rY�varsDictrr�	escapeValSs
z3CommandAction.replaceDynamicTags.<locals>.escapeValcsL|�d�}z�|}Wn"ty8��||���YS0t|�}�||�S)Nr)r�r<rrr�)r�rer�rrr�as
z2CommandAction.replaceDynamicTags.<locals>.substValr�zF-*csBt|�d��}zt�|�}Wnty2YdS0�d||�S)NrrpZF_)rr�rr<r�)r��tickDatarr�substTagssz2CommandAction.replaceDynamicTags.<locals>.substTag)	r#rr�rr�r�FCUSTAG_CREr	Z
buildShellCmd)rYr�rer�r�r�r)r�rerYr�r�r�rr�8s
z CommandAction.replaceDynamicTagscCst|dd�S)N�	_banEpochr)rXr6rrr�banEpoch�szCommandAction.banEpochcCs6|jdur&|jjjd|_|jj_n|jd|_dS)z�Increments ban epoch of jail and this action, so already banned tickets would cause
		a re-ban for all tickets with previous epoch.Nr)r^r�r�r�r6rrr�invalidateBanEpoch�s
z CommandAction.invalidateBanEpochTcCs|s|dur||jvrdS|�d|�}|r8|�||j�r<dS|rJ|�sJdS|j�d�|��|�d|�}|r�|�||j�s�d|j|<|j�d�dSd|j|<n8z|�|�Wnt	y�Yn0|j
||p�|jd	�|j�|��r|�||j��s|j�d�dSdS)
z0Executes a substituted `actioncheck` command.
		Nrz
<actioncheck>���z<Invariant check failed. Trying to restore a sane environmentz<actionrepair>rzUnable to restore environmentr�)
rwr�r�rlr`�errorr��criticalr�r�r�r�r)r$r�r�r�ZcheckCmdZ	repairCmdrrrr��s6
�
zCommandAction._invariantCheckc	s��dkr�j�d�dSz|d}Wnttfy>d}Yn0d}|r|�jr|��fdd�}�j||�dkd	�}|d
kr|dS�j��j|r�d|nd�jd
�}|dur���	||�}n�}��
|�j�}|d
7}|s�|d
krD|SqDdS)a�Executes a command with preliminary checks and substitutions.

		Before executing any commands, executes the "check" command first
		in order to check if pre-requirements are met. If this check fails,
		it tries to restore a sane environment before executing the real
		command.

		Parameters
		----------
		cmd : str
			The command to execute.
		aInfo : dictionary
			Dynamic properties.

		Returns
		-------
		bool
			True if the command succeeded.
		rp�
Nothing to doTr�rcs(�dkr$�j�d�s$�j�d�dSdS)Nr�Zactionrepair_on_unbanz,Invariant check failed. Unban is impossible.FT)r�rr`r�r�r�r$rr�
_beforeRepair�sz0CommandAction._processCmd.<locals>._beforeRepairr�r�rFr�r�N)r`ryr<�	TypeErrorrsr�r�r�rxr�r�rl)r$r�rer�Zrepcntr�r�r�rr�rr��s.


�zCommandAction._processCmdrocKsnt��tjkrt�d|�|s,t�d�dSt�*tj||fddd�|��Wd�S1s`0YdS)aIExecutes a command.

		Parameters
		----------
		realCmd : str
			The command to execute.
		timeout : int
			The time out in seconds for the command.

		Returns
		-------
		bool
			True if the command succeeded.

		Raises
		------
		OSError
			If command fails to be executed.
		RuntimeError
			If command execution times out.
		�	r�TF)�shell�outputN)	�logSys�getEffectiveLevel�logging�DEBUG�logry�	_cmd_lockr	r�)r�rlr&rrrr��s
zCommandAction.executeCmd)NF)r�)N)N)rpNN)N)NNT)N)ro)0r-rMrNrOr�r�rtr'rgr]r�rFr�rhr�r�r�r�r�r�r�r�rSr�rUrfr�rWrVr�rTr�r�r��re�compiler�r�r�r�r�r�r�r�r��staticmethodr��
__classcell__rrrzrrm sf	



'










Y

I

(
?rm)3�
__author__�
__copyright__�__license__r��osr��signal�
subprocess�tempfile�	threadingr��abcr�collections.abcr�ImportError�collectionsZ	failregexrZipdnsrZmytimer�utilsr	Zhelpersrrr
rrrrr-r��Lockr�Z
IPv6IsAllowedr�r�r�Z
COND_FAMILIESr�Z
DYN_REPL_TAGSr��update�objectrrRr~rmrrrr�<module>sN$

��
oc�